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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  displaying time left of a timer

displaying time left of a timer

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


Posted by Feantur   (70 posts)  [Biography] bio
Date Fri 27 Aug 2004 08:21 AM (UTC)
Message
Is there a way to display the time left of a timer somewhere? E.g. like a countdown?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Fri 27 Aug 2004 08:40 AM (UTC)
Message
http://www.gammon.com.au/scripts/function.php?name=GetTimerInfo

You can get it a few ways, your best bet is 13 though (although if youre into masochism, you could get the timer length, and the time it last was reset and also check the "at" flag).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Feantur   (70 posts)  [Biography] bio
Date Reply #2 on Fri 27 Aug 2004 07:06 PM (UTC)
Message
I've tried to set it up, unfortunately it only sends to the MUD screen itself. It would be nice to have something like the counter that shows how long I had the world open, just doing a count down instead of a count up (with automatical resets etc.).
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 30 Aug 2004 09:32 PM (UTC)
Message
If you want a constant update like that, you would need a second timer (eg. every second) that checks the first timer using what was suggested above (GetTimerInfo selector 13).

It could then use SetStatus to update the status bar at the bottom of the screen.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Feantur   (70 posts)  [Biography] bio
Date Reply #4 on Sat 18 Dec 2004 07:27 AM (UTC)

Amended on Sat 18 Dec 2004 07:28 AM (UTC) by Feantur

Message
My timer does the following atm:

world.SetStatus( "idle: " + (((600 - world.GetTimerInfo ("idle", 13))/60) + ":" + (600 - world.GetTimerInfo ("idle", 13))%60) );

This displays e.g. as follows:

idle: 8.5:35

What I'd like it to do is drop the .5 part and only display the integer part of the first call to GetTimerInfo. I've tried using Math.round - while it doesn't create an error it also doesn't deliver the result I'd expect.

Also tried CInt, which isn't recognised.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #5 on Sat 18 Dec 2004 07:31 AM (UTC)

Amended on Sat 18 Dec 2004 07:32 AM (UTC) by Flannel

Message
You could either subtract .5 from it then round, or use the floor function.

Floor will cause problems at negative values (well, not problems, but most people think intuitively that it will act like ceil does). Actually... both subtracting .5 and floor produce the same thing.

Edit: and Cint is VB, and thats converting from strings.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Feantur   (70 posts)  [Biography] bio
Date Reply #6 on Sat 18 Dec 2004 07:41 AM (UTC)
Message
Funnily the JScript help returned CInt as convert-to-integer method (at a second glance I saw the help file is actually on all of Microsoft's scripting languages).

Can't subtract .5 because it's not a constant bit. It changes through various values, as in parts of a minute.

Trying the floor method next.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #7 on Sat 18 Dec 2004 07:43 AM (UTC)
Message
No. Subtract one half, and then round.

3.5 becomes 3 (rounds to 3)
3.9 becomes 3.4 (rounds to 3)
3.0 becomes 2.5 (rounds to 3)

And if you look at the VERY top of the windows scrip file, it will tell you which section youre in. (VB or JS, etc)

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Feantur   (70 posts)  [Biography] bio
Date Reply #8 on Sat 18 Dec 2004 08:03 AM (UTC)
Message
Ok, this is a very crude way to do it probably, but it works now:

if (Math.round((((600 - world.GetTimerInfo ("idle", 13))/60)-0.5)) < 10)
{
if (((600 - world.GetTimerInfo ("idle", 13)) %60) < 10)
world.SetStatus( "idle: 0" + ( Math.round( ((600 - world.GetTimerInfo ("idle", 13))/60)-0.5 ) + ":" + "0" + (600 - world.GetTimerInfo ("idle", 13))%60) );
else
world.SetStatus( "idle: 0" + ( Math.round( ((600 - world.GetTimerInfo ("idle", 13))/60)-0.5 ) + ":" + (600 - world.GetTimerInfo ("idle", 13))%60) );
}
else
world.SetStatus( "idle: " + ( Math.round( ((600 - world.GetTimerInfo ("idle", 13))/60)-0.5 ) + ":" + (600 - world.GetTimerInfo ("idle", 13))%60) );

Any suggestions for improvement?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #9 on Sat 18 Dec 2004 08:06 AM (UTC)
Message
What are you trying to do with that? Keep it from going to one digit?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Feantur   (70 posts)  [Biography] bio
Date Reply #10 on Sat 18 Dec 2004 08:07 AM (UTC)

Amended on Sat 18 Dec 2004 08:08 AM (UTC) by Feantur

Message
It displays how long I'm idle so far (output is "idle: 05:32" etc., counting upwards) - the ifs and elses only add leading zeros in case they are needed for cosmetical reasons.
[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.


23,033 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]