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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Fri Jan 12, 2007 9:58 pm   

Randomised #ALARM question
 
Greetings,

I'm trying to make an alarm which doesnt really fire every exactly x seconds, but every randomised amount of seconds.

So, what I'd like to do is

#AL %random(5,10) {<commands>}

However I dont think this works.

with #EXEC %concat .... I think I could setup an alarm for a randomised amount of time, but it would fire at exactly that time each time.

So I suppose I need a one-shot alarm which finishes by setting up the next one-shot alarm etc

Problem is I have no clue on how to do it

Someone can help me?

TIA
Gats
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jan 12, 2007 10:57 pm   
 
#alarm *@varname {varname = %random(x,y);#say Time: %time()}

You will notice a little bit of funkiness when you try to go look at the alarm, but it works.
_________________
EDIT: I didn't like my old signature
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Jan 12, 2007 10:58 pm   
 
Yes, that'll set alarm to a random time when it's created, not every time it fires. The easy way to do this is to use the %alarm function to change the timing of the alarm:

#alarm "TestAlarm" %random(5,10) {do whatever;#noop %alarm(TestAlarm,%eval(%random(5,10)*1000))}

should work - if it doesn't, set another alarm to change the first alarm's time 0.5 secs after it fires.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Fri Jan 19, 2007 12:57 pm   
 
Hi Guys,

Had a little play with this and the easiest I found is :

#ALIAS repeatit {
delay=%random(10,20)
<do whatever you need doing>
#IF (@repeating) {#ALARM +@delay {repeatit}}}

nm eventual syntax errors, am at the office where I dont have zmud installed, but it works fine at home.

repeating is a boolean that can be unset to stop the cycling

This looks like an infinite loop, but fortunately isn't.

Cheers,
Gats
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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