|
dragonisk Newbie
Joined: 15 Jan 2011 Posts: 5
|
Posted: 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? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: 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))} |
|
|
|
|
dragonisk Newbie
Joined: 15 Jan 2011 Posts: 5
|
Posted: Sat Feb 05, 2011 8:18 am |
thank you! I'll definitely try these out.
|
|
|
|
|
|