[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Interesting Timer problem.

Interesting Timer problem.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by David Berthiaume   (202 posts)  [Biography] 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.
[Go to top] top

Posted by Essidus   (16 posts)  [Biography] 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"
[Go to top] 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] Refresh page

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]