Gammon Forum
Entire forum
MUSHclient
General
Interesting Timer problem.
Interesting Timer problem.
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| David Berthiaume
(202 posts) bio
|
Date
| Mon 06 Feb 2006 11:59 AM (UTC) |
Message
| I use oneshot timers a lot in my scripting. Telling me when mobs repop, when it's safe to log out, things like that.
Being who I am, I was wondering if there was a way to make a timer that when there was 5 seconds left would output a count down?
Say it's a 2 minute timer, I'd like some kind of warning that the timer is about to finish.
Without having to do multiple timers to cound down the last 5 seconds, which would make for 6 timers. | top |
|
Posted by
| Essidus
(16 posts) bio
|
Date
| Reply #1 on Mon 06 Feb 2006 02:34 PM (UTC) |
Message
| You could set it up with a case statement. You'd need a single variable, and of course the case statement itself. First, dim the variable (V, for simplicity) as a short. When the trigger is fired, give V the value of 120(as the number of seconds) Since you want it to do something with every second, you'll have to seperate out the seconds individually. This is where the case statement comes in. You have it select case V > 5 and have the only bit of code in there as V-=1. This is exactly the same as a do loop, until you get to the point where you need the code to act differently, hence the select case. You'd then give it a second case of V > 5 AND V < 0, and give this portion a script that displays a message on your screen, plus the value of V before doing another V-=1. Finally, V=0 or for posterity, v<1 would contain the real script you wanted it to follow, plus the command to turn off the timer so that it doesn't keep firing. It's all really simple. Now that I've said all that, here's more or less what the case system would look like in the timer. (In VB, please bear with me)
Select Case V
Case V > 5
'everything above 5 seconds
V -= 1
Case V < 6 And V > 0
'Your countdown (cstr is there for posterity, it's normally not needed)
note "Time remaining: " + cstr(V)
V -= 1
Case V < 1
'running the effect, and turning off the countdown
runeffect()
enabletimer "countdown", False
End Select
and your trigger should have something to this effect:
setvariable "V" 120
enabletimer "countdown", true
resettimer "countdown"
| top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
9,753 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.