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
The Raven

Joined: 13 Oct 2000
Posts: 463

PostPosted: Wed Jul 10, 2002 10:01 pm   

Countdown (or up) Timer
Note: This script will not run on versions of zMud prior to 6.26Beta, because it uses multi-state triggers.

On Battletech 3030, I have a technician character. Most of the time on the MUX is spent repairing mechs that are damaged. It takes real life time to do these repairs, limiting how much one person can do.

To keep track of my time, I made a countdown timer, and I thought it was interesting enough to warrent posting it here. In particular, the alias 'modtechtime' could be useful in many situations when you need to manually handle a timer, and want to display it nicely using hours minutes and seconds, instead of just thousands of seconds.

#CLASS {Technician} {setdef}

At random intervals between 5-20 minutes it checks my tech time, to recalibrate the timer as it drifts slightly.
#ALIAS checktechtime {
#ALARM +%random( 300, 1200) {checktechtime}

This multi-state trigger gags the output of the +techtime command, and captures the time into the TechTimeX variables... Days, Hours, Minutes, and Seconds. At the end of the states, it turns on the #TIMER (if it is not already on) with a 1 second loop.
#TRIGGER {^ Technician Time For: Tikatt Ren} {#GAG}
#COND {^$} {#GAG}
#COND {^-------------------------------------------------------------------------------} {#GAG}
#COND {^Logged Repairs: (&TechTimeD).(&TechTimeH):(&TechTimeM):(&TechTimeS) Remaining Time:} {#GAG}
#COND {^Rested Time:} {#GAG}
#COND {^-------------------------------------------------------------------------------} {
#IF (not @TechTimer) {
#TIMER 1 {modtechtime -1} 0 0
#VAR TechTimer 1

Here is the fun alias. It takes one parameter, the number of seconds to add or subtract from the timer. It then adjusts the clock variables accordingly, including adding padded 0s as necessary. If the timer goes negative, then it sets all the variables to 0 and turns off the tick timer.
#ALIAS modtechtime {
#MATH TechTimeS {@TechTimeS + %1}
#IF (@TechTimeS >= 60) {
#MATH TechTimeS {@TechTimeS - 60}
#MATH TechTimeM {@TechTimeM + 1}
#IF (@TechTimeM >= 60) {
#MATH TechTimeM {@TechTimeM - 60}
#MATH TechTimeH {@TechTimeH + 1}
#IF (@TechTimeH >= 24) {
#MATH TechTimeH {@TechTimeH - 24}
#MATH TechTimeD {@TechTimeD + 1}
#IF (@TechTimeS < 0) {
#MATH TechTimeS {@TechTimeS + 60}
#MATH TechTimeM {@TechTimeM - 1}
#IF (@TechTimeM < 0) {
#MATH TechTimeM {@TechTimeM + 60}
#MATH TechTimeH {@TechTimeH - 1}
#IF (@TechTimeH < 0) {
#MATH TechTimeH {@TechTimeH + 24}
#MATH TechTimeD {@TechTimeD - 1}
#IF (@TechTimeD < 0) {
#VAR TechTimeD 0
#VAR TechTimeH 0
#VAR TechTimeM 0
#VAR TechTimeS 0
#VAR TechTimer 0
#IF ((@TechTimeS < 10) and (@TechTimeS >= 0)) {
#MATH TechTimeS {@TechTimeS + 0}
#VAR TechTimeS {0@TechTimeS}
#IF ((@TechTimeM < 10) and (@TechTimeM >= 0)) {
#MATH TechTimeM {@TechTimeM + 0}
#VAR TechTimeM {0@TechTimeM}
#IF ((@TechTimeH < 10) and (@TechTimeH >= 0)) {
#MATH TechTimeH {@TechTimeH + 0}
#VAR TechTimeH {0@TechTimeH}
#IF ((@TechTimeD < 10) and (@TechTimeD >= 0)) {
#MATH TechTimeD {@TechTimeD + 0}
#VAR TechTimeD {0@TechTimeD}

This is one example of how I use the timer. It does not let me accidentally do more repairs when my tech time is over an hour already.
#ALIAS fix {#if (@TechTimeH > 0) {#ECHO Tech time too high, access denied.} {~fix %-1}}

Simple Status bar to display my tech time.
#STAT {Tech Time: @TechTimeD~.@TechTimeH~:@TechTimeM~:@TechTimeS}
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