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
dragonisk
Newbie


Joined: 15 Jan 2011
Posts: 5

PostPosted: Fri Feb 04, 2011 5:19 pm   

Need help using a timer...
 
Hi again..

I want to do some testing in a mud but I find it hard to determine the timespan between each action I do. So I thought why not make a trigger that counts the timespan between these actions? Problem is I don't know where to start.. So here's what I want to happen..

Description:

Trigger Line 1: You inhale deeply.
What I want to happen: zMUD starts a timer, nothing shown on the output window yet though.

Trigger Line 2: You exhale.
What I want to happen: zMUD prints "<< You exhaled after ##.### seconds >>" on the output window

Example:
Code:

- You inhale deeply.
-
- (after 2.550 seconds)
-
- You exhale.
- << You exhaled after 2.550 seconds >>


Anyone know how to do this?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Feb 04, 2011 6:44 pm   
 
You can't, or rather, you can't do it accurately enough. The basic concept of a timer is simple and easy to do, it's just a matter of the precision you're looking for:

#alarm "almTimer" -.501 {#add TimeInMilliseconds 501}

#trigger {^You inhale deeply.$} {#T+ almTimer;TimeInMilliseconds = 0}
#condition {^You exhale.$} {#T- almTimer;#say %format("<< You exhaled after &0.3f seconds >>",%eval(@TimeInMilliseconds / 1000.00))}

I don't think ZMud can go below .501 seconds for a timer, though.
_________________
EDIT: I didn't like my old signature
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sat Feb 05, 2011 4:41 am   
 
You can get it more accurate than that by using the %secs function.

Code:

#TRIGGER {^You inhale deeply.$} {#VAR breath_timer %secs}
#TRIGGER {^You exhale.$} {#SAY %format("<< You exhaled after &0.3f seconds >>", %eval((%secs - @breath_timer) / 1000.0))}
Reply with quote
dragonisk
Newbie


Joined: 15 Jan 2011
Posts: 5

PostPosted: Sat Feb 05, 2011 8:18 am   
 
thank you! I'll definitely try these out.
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