|
MCrews17 Beginner
Joined: 16 Oct 2011 Posts: 13
|
Posted: 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?
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Mar 19, 2014 4:44 am |
Check out the #waitfor command.
|
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: 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.
|
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: 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. |
|
|
|
MCrews17 Beginner
Joined: 16 Oct 2011 Posts: 13
|
Posted: 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} |
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: 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.
|
|
|
|
MCrews17 Beginner
Joined: 16 Oct 2011 Posts: 13
|
Posted: 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} |
|
|
|
|
|