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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Sun Sep 09, 2007 9:51 pm   

#Waitfor - Clarification?
 
Could anyone go over the syntax of #Waitfor?

Also, does it ever time out?

I.e.

#waitfor You receive


If you never receive that line does it keep running the background?


Thanks guys :)

And Zugg, 2.0 ROCKS :)
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sun Sep 09, 2007 11:23 pm   
 
#WAITFOR "some text from the mud"

That's the syntax I use, anyway, and it works quite well. I think you can use inline regex, too, but I haven't touched that yet.

If you never receive that line from the mud, it stays paused as a background thread... probably uses no more resources than a standard #TRIGGER
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Sep 09, 2007 11:56 pm   
 
Thinjon is right - the text from the MUD can be any valid pattern syntax (same as triggers) including the new %/regex/% syntax.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Mon Sep 10, 2007 12:13 am   
 
Ok great... New question.


If your #waitfor is in the middle of a trigger.

I'm assume the trigger will still trigger again, but will now you have 2 #waitfors running in the background?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Sep 10, 2007 12:21 am   
 
Yep. Every time a trigger fires or an alias runs (or whatever), a new thread is created (or one that's finished executing is reused).
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Mon Sep 10, 2007 2:59 am   
 
Er, you should clarify that last statement... Isn't it only an alias or trigger or whatever that runs that contains a #WAIT, #WAITFOR, etc. (any of those sort of commands)? Normally there is one thread processing all the triggers if you don't use any of those commands, I believe.
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Mon Sep 10, 2007 10:01 am   
 
Ok... so I did some testing.


There is apparently no expiration time on #Waitfor commands.


I had a trigger activate 3 times with a #Waitfor command without the #waitfor being fullfilled.

Roughly 5 minutes later the #waitfor was fullfilled and I was spammed :(


Is there no way to limit this?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Sep 10, 2007 11:05 am   
 
Seb wrote:
Isn't it only an alias or trigger or whatever that runs that contains a #WAIT, #WAITFOR, etc. (any of those sort of commands)?


Nope. Any script at all.

Zugg wrote:
whenever CMUD needed to execute a script (or a trigger, etc) it would create a new "code" thread, and then execute the thread


Haldrik wrote:
Is there no way to limit this?


Not using #waitfor, no. You can use #temp, though, and give the temporary trigger an id - that'll mean that it'll only be created once and then deleted once it executes. You could also use a non-temporary trigger and have the first part turn it on, and then turn itself off. Since #t+ doesn't do anything to a trigger that's already on, nothing will happen if the first trigger runs more than once.

EDIT: Now that I think about it, you could MAYBE use a command from the second trigger to resume the thread that's using #waitfor. You need to use #thread to give the first thread a name, and then you can use the resume command (don't remember the syntax - search Zugg's blog) to start it up again. Be careful doing that, though.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Mon Sep 10, 2007 6:43 pm   
 
Fang Xianfu wrote:
Seb wrote:
Isn't it only an alias or trigger or whatever that runs that contains a #WAIT, #WAITFOR, etc. (any of those sort of commands)?


Nope. Any script at all.

Zugg wrote:
whenever CMUD needed to execute a script (or a trigger, etc) it would create a new "code" thread, and then execute the thread


EDIT: Now that I think about it, you could MAYBE use a command from the second trigger to resume the thread that's using #waitfor. You need to use #thread to give the first thread a name, and then you can use the resume command (don't remember the syntax - search Zugg's blog) to start it up again. Be careful doing that, though.


Actually, Haldrik, the place you want to look is this thread:
New CMUD Feature: Sequential Scripting Threads!

Fang, I believe you are incorrect. From the above thread (typo corrected):
Zugg wrote:
As long as you don't use #WAIT or #WAITFOR (or any other command that is added to control the thread), then it will still work the same way as the current version. In other words, triggers still wait for themselves to finish before going to the next trigger (unless the trigger thread is suspended for some reason).
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Sep 10, 2007 8:59 pm   
 
Type #WAITFOR on the command line and then press the F1 key to view the Quick Reference and you'll see that there is an optional second argument to specify the timeout. So the syntax is:

#WAITFOR {pattern} timeout

For example:

#WAITFOR {pattern to continue} 5000

to wait for 5 seconds. If the timeout expires, the script will be aborted at the #WAITFOR and the commands after it will be skipped.

It's always good to remember the F1 Reference panel for getting help on new commands/functions.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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