Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Tue Jun 15, 2004 6:40 am   

Countdown timer
 
Don't know if anyone's interested, but thought i'd post this:

Code:

#CLASS {Timers}
#ALIAS timeron {
  #MATH secsleft (@timermin*60 + @timersecs)
  #BUTTON 5 "@secsleft" {} {} {} {@secsleft} {} {} {Size} {160} {23} {} {} {} {32812} {} {Gauge||12|@timermin*60+@timersecs|5|0} {} "Timers|Timerbuttonclass" {Explore|Inset} {} {Countdown}
  #T+ update
  }
#ALIAS timeroff {
  #DELCLASS Timers|Timerbuttonclass
  #T- update
  }
#ALIAS stopt {#T- update}
#ALIAS startt {#T+ update}
#VAR timermin {0}
#VAR timersecs {30}
#VAR secsleft {0}
#ONINPUT {timer (%d)m (%d)s} {
  timermin = %1
  timersec = %2
  #IF (@timersec > 60) {
    #UNTIL (@timersec < 60) {
      #ADD timermin 1
      #ADD timersec -60
      }
    }
  #GAG
  #ECHO Timer now at @timermin minutes and @timersec seconds.
  }
#ALARM "update" {1} {
  #IF (@secsleft>0) {#ADD secsleft -1} {
    #ECHO Times up!
    #PLAY c:WINDOWSMediading.wav
    timeroff
    }
  } "" {disable}
#ONINPUT {timer (%d)s} {
  timersec = %1
  timermin = 0
  #GAG
  #ECHO Timer now at @timermin minutes and @timersec seconds.
  }
#CLASS 0


USE:

"timer *m *s" where you replace the "*"'s with numbers will set the timer and then "timeron" will start it. You can also do the same thing with just the seconds, no minutes.

"timeroff" will turn off the timer

"stopt" will pause the timer

"startt" will restart the timer after being paused.
Reply with quote
Mumra
Wanderer


Joined: 12 Feb 2003
Posts: 93
Location: USA

PostPosted: Tue Jun 15, 2004 11:44 pm   
 
I was just curious about this, what Version are you using this on? On my version, as soon as I type startt, 2 seconds later, no matter what, it says Times up! no matter what I set it to.
Reply with quote
Kalgores
Newbie


Joined: 04 Feb 2005
Posts: 3
Location: Melbourne, Australia

PostPosted: Fri Feb 04, 2005 5:51 am   
 
Aarlot... i have been looking thru the help files of Zmud and on forums for some sort of a timer for a while now. Yours is the first like this that i've found. Wow!

It worked a charm for me, but i couldnt help tinkering with a copy of it too.

I hope you dont mind that I''ve modified it to count 'upwards' instead of a countdown, so it keeps an approximate time like a stopwatch... its to go with an xp tracker.

Included below for your reference...


Code:

#CLASS {Timersimple}
#ALIAS starttime {#T+ timer}
#ALIAS stoptime {#T- timer}
#ALIAS reporttime {time=@hours h:@mins m:@secs s;#echo We have been running for @time, or thereabouts.}
#ALIAS cleartime {hours=0;mins=0;secs=0;time=0;#T- timer}
#VAR secs {1}
#VAR mins {0}
#VAR hours {0}
#VAR time {0 h:0 m:0 s}
#ALARM "timer" {1} {#IF (@secs>0) {#ADD secs 1} {};#IF (@secs>59) {#ADD mins 1;secs=0;#ADD secs 1} {};#IF (@mins>59) {#ADD hours 1;mins=0;secs=0;#ADD secs 1} {}} "" {disable}
#CLASS 0


#EDIT 07/03/05 Thanks DaHart85, secs should be 1, not 0.

"starttime" and "stoptime" work the timer, now uniquelly named 'timer' so as not to interfere with yours.

"reporttime" reports the timer.
"cleartime" stops and clears the timer.

I'd like to include this with the Full Xp tracker i'm working on, I will credit you appropriately for the timer. Any info or suggestions with this timer are welcome too.

Good Coding

Kalgores
_________________
Not all those who wander are lost.
-JRR Tolkien

Last edited by Kalgores on Mon Mar 07, 2005 7:29 am; edited 1 time in total
Reply with quote
DaHart85
Beginner


Joined: 25 Feb 2005
Posts: 10
Location: Fort Wayne, IN

PostPosted: Sun Mar 06, 2005 5:25 am   
 
I couldn't figure out how to get the timer to countup Kalgores, any chance you can post the whole code because mine doesn't echo the right time on the reporttime, it always says 0 because I don't have your trigger titled "timer" I think. If it's something on my end, I'd appreciate any clarification you could provide. Cool idea fellas, hope I can get it to work. :-)


EDIT: Aarlot, On the countdown, you use both the variable timersec (which doesn't exist in your code) and timersecs (which does exist). That's the only problem I was having with the countdown.


EDIT #2: Kalgores, you need to have the variable "secs" set to 1 instead of zero, otherwise secs>0 won't cause it to #ADD secs 1 because secs=0 not secs>0 So the timer is 1 second off, but it works perfectly otherwise.
Reply with quote
Kalgores
Newbie


Joined: 04 Feb 2005
Posts: 3
Location: Melbourne, Australia

PostPosted: Mon Mar 07, 2005 8:28 am   
 
DaHart85: That was all the code for that timer, but you said you did get it working. Cool. Thanks for your constructive reply, in the end though, i didnt continue using that timer for accuracy purposes. I found another way around it. See below ;)

Using a complicated '#MATH' and an inbuilt Zmud variable i finally found and should have known of sooner.... '%ctime'

the '%ctime' is the time connected to the mud, its a number you can use very handily for counting, so long as you know when you started counting, which of course you just make a unique variable of the %ctime, like 'startingtime' or whatever else.

Code:

#CLASS {statuswindow|timeralone}
#ALIAS tracker {dothemaths;#echo We have run @hours hours, @mins minutes and @secs seconds, or thereabouts.}
#ALIAS starttime {hours=0;mins=0;minsrem=0;secs=0;secsrem=0;startingtime=0;stoppingtime=0;time=0;time2=0;startingtime=%ctime}
#ALIAS stoptime {stoppingtime=%ctime}
#ALIAS dothemaths {hours=0;mins=0;minsrem=0;secs=0;secsrem=0;stoptime;#MATH time @stoppingtime-@startingtime;#IF (@time>3599) {#MATH hours @time/3600;#MATH minsrem @hours*3600;#MATH time2 @time-@minsrem;#IF (@time2>59) {#MATH mins @time2/60;#MATH secsrem @mins*60;#MATH secs @time2-@secsrem}};#IF (@time<3559) {#MATH mins @time/60;#MATH secsrem @mins*60;#MATH secs @time-@secsrem}}
#CLASS 0


you can use all that to pull some really nifty stuff, like xp/minute, as i have done.

for the full code of my valheru mud xp tracker/timer jump on to my website... you can easily change/convert it for another mud.

http://www.xanthor.com.au/dl/xptrackerandtimer.txt (now uploaded)

go ahead and modify if you want, pls post anything cool you make/discover. Go open source!!!

Good coding!

Kalgores
_________________
Not all those who wander are lost.
-JRR Tolkien
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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