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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
MCrews17
Beginner


Joined: 16 Oct 2011
Posts: 13

PostPosted: Wed Mar 19, 2014 3:51 am   

Global variables and loops
 
Running into trouble with this:

Code:


#VAR IdentifyWait 8000

#ALIAS QuickID($ITEM) {
  swQuickID=1
  #WHILE (@swQuickID=1) {
     identify $ITEM
     #WAIT @IdentifyWait
  }
}

#TRIGGER {^You identified} {
  swQuickID=0
}


This trigger will end the loop, but once it has ended I'll need to wait the duration of the WAIT time before running it again. Otherwise it will run two threads. Does anybody know how to prevent this from happening? Shocked
Code:
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Mar 19, 2014 4:44 am   
 
Check out the #waitfor command.
Reply with quote
Scarn
Apprentice


Joined: 24 Jul 2005
Posts: 137

PostPosted: Wed Mar 19, 2014 10:11 am   
 
Can you explain what the script does? I've ran into endless problems with WAIT, mainly due to the way in which MUDs recieve data. Now I prefer to activate/deactivate separate triggers or use WAITFOR as Daern has suggested.
Reply with quote
Scarn
Apprentice


Joined: 24 Jul 2005
Posts: 137

PostPosted: Wed Mar 19, 2014 10:14 am   
 
#VAR IdentifyWait 8000

#ALIAS QuickID($ITEM) {
swQuickID=1
#WHILE (@swQuickID=1) {
identify $ITEM
#WAITFOR {^You identified} 10000 {swQuickID=0} {}
}
}

In this example rather than running the alias 8 seconds later, it will wait until you see "You identified" and then run it again, this should stop multiple threads. The 1000 is just a time out to stop looking for the pattern.
Reply with quote
MCrews17
Beginner


Joined: 16 Oct 2011
Posts: 13

PostPosted: Thu Mar 20, 2014 12:14 am   
 
Oh, sure. It is a script I use to identify items. It waits 8 sec, then it keeps trying to identify the item until it succeeds.

I tried the #waitfor and it works great. Thanks! I'm still kinda confused about the capabilities of #waitfor, there isn't much documentation.
Can #waitfor account for more than one match? Like "You identified" and "You recognized"

ex: I tried to use it to account for two matches instead of just one. Unfortunately, the syntax is incorrect.

Code:
#waitfor {You identified|You recognized} 10000 {swQuickID=0}
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Mar 20, 2014 12:26 am   
 
Read the pattern matching helpfile and try that. Not sure waitfor accomodates stringlist patterns, but if it does it would use core patternmatching syntax.
_________________
EDIT: I didn't like my old signature
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Mar 20, 2014 2:39 am   
 
You need a second set of braces: one to go around the entire pattern per the #waitfor syntax (#waitfor {pattern} ... ), and then one to go around the list of matches as you would do in normal patterns.
Reply with quote
MCrews17
Beginner


Joined: 16 Oct 2011
Posts: 13

PostPosted: Fri Mar 21, 2014 12:45 am   
 
Ok, thanks Daern. I found the syntax on a previous post for #waitfor.

#waitfor {{match1|match2|match3...}} 10000 {command}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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