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
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Tue Mar 27, 2007 6:03 pm   

Blocking without use of #WAIT command
 
What is the best way to pause your script, wait for some amount of time and then continue the script?

I use it all the time but is still using #wait. It gives me some trouble however so I would like to do this without using this command.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Mar 27, 2007 6:31 pm   
 
The #alarm command is the preferred method. It's a lot more versatile and has a lot more options (including time-of-day-based matching) than #wait. For simple aliases you'll want something like this:

#alias commands {something;#alarm +5 {something else};#alarm +10 {something else else}}

or this

#alias commands {something;#alarm +5 {something else;#alarm +5 something else else}}}

depending on which one you find easier to read.

Alarms are actually triggers, but they match a time instead of a pattern. So the #alarm syntax works exactly the same as the #trigger syntax in that you can give them an id, specify a class for them to be created in, and so on. Alarms with ids can be controlled with #t+ and #t- (just like normal triggers) and with the #suspend command and the %alarm function too. There's definitely a bug with one of these methods (I believe #suspend) where the alarm keeps counting down while it's off, going into negative numbers and never actually executing its command.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Tue Mar 27, 2007 7:41 pm   
 
I tried this and it seemed to work fine until CMUD suddenly went berserk and I had to shut it down. When I started it up again there was about 6000 unfired alarms which I then deleted. Any ideas why?

Code looks like this:

#WHILE (@awaitingFeedback == true) {
#ALARM {+0.50} {}
}

There is a trigger that sets the variable or I can set it to false manually by pressing a button.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Mar 27, 2007 8:06 pm   
 
Yes, that's because, like I said, the #alarm command creates a trigger that matches a set time, it doesn't delay commands after it. That's one situation in which you have to use #wait to have it work that way. One possible solution would be to use something like this:

#alias start {#t+ WhileAlarm}

#alarm "WhileAlarm" 0.501 {#if (!@awaitingFeedback) {continue;#t- WhileAlarm}}
_________________
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 » 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