Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Aeri
Newbie


Joined: 25 Sep 2006
Posts: 8

PostPosted: Fri Dec 01, 2006 4:21 am   

Detecting multiple repeats
 
I got a question, and hopefully an easy one to answer.

Lets say you get an emit like this...

A BUG JUMPS ON YOUR SHOULDER

The emit continues to repeat itself every five seconds, and I want an alert to beep at me when it recognizes the repeat.

Something even better would be for the script to pink up on all caps and beep at me when it sees that. Any help would be awesome!! Thanks in advance.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Dec 01, 2006 8:52 am   
 
#var BugCount 0
#trig {A BUG JUMPS ON YOUR SHOULDER} {#if (@BugCount > 0) {#beep} {#add BugCount 1}}
#alias ResetBugs {#var BugCount 0}

Should do what you want. The first time, it'll add one to the bugcount, but after that it'll beep each time until you reset it.

Picking up on any string in caps is a big more difficult, mostly because you'll need a trigger with the pattern (*) which will check EVERYTHING and is going to slow you down. Anyway:

#trig {^(*)$} {#if (%1 = %upper(%1)) {do whatever you want if it is} {do whatever you want if it isn't}}

I'm not even sure if this'll work because it requires the = to be case sensitive, which it might or might not be.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Dec 01, 2006 1:40 pm   
 
Fang, isn't there a switch in the triggers that says something like "Literal" as in if it's NOT in caps it won't trigger?

Also, since you might want to have #if (@BugCount = 0) only because you might want to have the beep asap
_________________
http://www.Aardwolf.com
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Dec 01, 2006 3:02 pm   
 
There's a "Case" option to make them case sensitive if that's what you mean.

If you change it to @BugCount = 0 you then have to swap round the commands, since it'll beep if it's 0 and add 1 if it's not (which will just beep every time). You could change it to @BugCount = 1 if you wanted, but with > 0 he could also add "#add BugCount 1" to the #beep command as well and count the number of times it's repeated, if that info's useful. He specified that he wanted it to beep on every time after the first, and using > 0 seems to match the idea behind the script in my mind.
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Dec 01, 2006 7:19 pm   
 
oh duh on the = 0 I'd meant => 0

*mutter* thought of that when I was only on my 1st cup of coffee and didn't think of that since neither would be right :-)
_________________
http://www.Aardwolf.com
Reply with quote
Aeri
Newbie


Joined: 25 Sep 2006
Posts: 8

PostPosted: Sat Dec 02, 2006 6:27 pm   
 
Hmmmm.. I got the first one to start working. And it works great. The all caps is what I am trying to accomplish now. It seems that any kind of capitol letter triggers the trigger.

Edit - Actually. Any kind of text will set the trigger off...
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Dec 02, 2006 7:23 pm   
 
The "anything in capitals" trigger I posted probably won't work - it requires the = operator to be case-sensitive, and I don't think it is. I'm not sure if there's a way to do it... is this a job for =~?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Aeri
Newbie


Joined: 25 Sep 2006
Posts: 8

PostPosted: Tue Dec 05, 2006 10:42 pm   
 
Bah! I have been trying with this for a few days now, and I cannot seem to get anything work... Guess there is no way to capture an emit in all caps. (Random emits).. Confused
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Dec 05, 2006 10:51 pm   
 
Are they truly random, or are they just random from a list of possibilities? You could just create more than one trigger, or a trigger with a list of parameters:

#trig {{A BUG JUMPS ON YOUR SHOULDER|A HAMSTER BITES OFF YOUR TOES}} {do something}

and so on.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Aeri
Newbie


Joined: 25 Sep 2006
Posts: 8

PostPosted: Tue Dec 05, 2006 10:53 pm   
 
They are truly random. It could be ANYTHING in capitol letters. That's why this is such a hard riddle for me to solve.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Dec 05, 2006 10:58 pm   
 
That is a bit of a conundrum, yes. I'm not sure how exactly =~ works in expressions (according to the help it matches strings, which may be what you're looking for since the string "SOMETHING" and the string "something" aren't matches). It's possible that this will work:

#trig {(*)} {#if (%1 =~ %upper(%1)) {do something} {do something else}}

but I make no guarantees.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Aeri
Newbie


Joined: 25 Sep 2006
Posts: 8

PostPosted: Tue Dec 05, 2006 11:02 pm   
 
There is a syntax error pointing towards the % before the upper when I try that..
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Dec 05, 2006 11:42 pm   
 
Try enclosing %upper() in brackets. I'm not even sure if that syntax still works any more, I haven't seen it used anywhere in ages and ~ is the quote character so that might be doing something.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net