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
Gwaethiel
Beginner


Joined: 23 Feb 2011
Posts: 13

PostPosted: Wed Mar 14, 2012 11:53 am   

Help with #waitfor
 
Hi!

When i'm playing on zMUD i have script which look, f.e.:

Quote:

[...]
sd
#wa %random(7000, 8534)
n
sd
#wa %random(7000, 8534)
ne
sd
#wa %random(7000, 8534)
e
sd
[...]


Where 'sd' is alias with search something and it's take about 7seconds, and after waiting 7-8,5s it send next command to mud.

I found #WAITFOR in cMud and i want to improve my script with it, but i don't know how i must change my script with #wait to #waitfor.

After sd MUD can send me messages:
Znajdujesz (*)
Szukasz wszedzie, ale nie znajdujesz zadnych ziol.
Nie udaje ci sie znalezc niczego interesujacego.
Nie znajdujesz zadnych ziol.

I though to change
Quote:

sd
#wa %random(7000, 8534)
w
sd

to
Quote:

sd
#WAITFOR {Znajdujesz (*)|Szukasz wszedzie, ale nie znajdujesz zadnych ziol.|Nie znajdujesz zadnych ziol.|Nie udalo ci sie znalezc niczego interesujacego.}
#wa %random(100, 1500)
w
sd


But it didn't work. Any solutions?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Mar 14, 2012 12:25 pm   
 
When you make an anonymous variable in a pattern you must enclose that within its own pair of {curly braces} as well.

#WAITFOR {{Znajdujesz (*)|Szukasz wszedzie, ale nie znajdujesz zadnych ziol.|Nie znajdujesz zadnych ziol.|Nie udalo ci sie znalezc niczego interesujacego.}}
_________________
Discord: Shalimarwildcat
Reply with quote
Gwaethiel
Beginner


Joined: 23 Feb 2011
Posts: 13

PostPosted: Wed Mar 14, 2012 12:38 pm   
 
Cool, it works! Thank you.

So, i have another question. I hope you can help me too.

In zMUD when i run trigger and push ESCAPE, trigger stop at all. In cMUD when i push ESC, client send next command after #wait. Can i make ESC a 'killer' for longer triggers?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Mar 14, 2012 3:50 pm   
 
#WAIT was not working as intended in zMUD, so in that sense, likely not.

#WAITFOR does has a timeout feature you can use however, if you dont want them waiting indefinitely.

Alternatively, if certain #WAITFOR lines are more of an optional nature, you may want to use a fully separate trigger instead.
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Mar 14, 2012 8:41 pm   
 
Zmud did not have threads, so everything ran in the main thread and hitting ESC would halt it. Cmud has proper threads, and using #WAIT or #WAITFOR will put that script into a separate thread. The advantage is that you can have those scripts running in the background while you continue to do other things on the command line. The disadvantage is that if you aren't careful, your background scripts might be accidentally dependent on something that gets changed by another thread.

It is possible to kill a background thread, but usually you should avoid it. Often, a better way is to write the thread in such a way that it halts itself if there are problems, or when some state changes. For instance, you could create a variable named @RunBackground, and in your background scripts you write in several places where it checks whether @RunBackground is true or false. Then, if you need to halt the background scripts, you execute an alias or fire a trigger that changes the @RunBackground variable. That's just one possible way to do it.
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