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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Tue Jun 08, 2004 7:09 am   

Buttons staying up to date, expression triggers
 
I have two problems here, actually. I'm attempting to make a timer system that does not use the tick timer, since I use that for other things. I'm using the %time functions, and it works great so far, except in two minor details. Here is the coding I have so far:

Code:


#CLASS {Timers}
#ALIAS timeron {
  #MATH starttime (%eval( @tinsec) + %eval( @tinmin*60) + %eval( @tinhour*3600))
  #MATH endtime (@starttime + @timersec + %eval( @timermin*60))
  #IF (@endtime > 86399) {#ADD endtime -86400}
  #BUTTON 5 "%eval( @endtime - %eval( %time( s) + %eval( %time( n)*60) + %eval( %time( h)*3600))) seconds" {} {} {} {%eval( @endtime - %eval(%time( s) + %eval(%time( n)*60) + %eval(%time( h)*3600)))} {} {} {Size} {160} {23} {} {} {} {32} {} {Gauge||12|%%eval(@endtime - @starttime)|5|7} {} "Timers|Timerbuttonclass" {Explore|Inset} {Time left on Timer} {Timershow2}
  }
#ALIAS timeroff {#DELCLASS Timers|Timerbuttonclass}
#VAR timermin {2}
#VAR timersec {6}
#VAR tinsec {%time( s)}
#VAR tinmin {%time( n)}
#VAR tinhour {%time( h)}
#VAR starttime {83688}
#VAR endtime {83814}
#VAR secsleft {%math( @endtime - (%time( s) + (%time( n)*60) + (%time( h)*3600)))}
#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.
  }
#TRIGGER (%eval( @secsleft) = "0") {
  #ECHO Time's up!
  timeroff
  }
#CLASS 0


My problem is that, since there is no variable being changed for the time left, the gauge does not update unless clicked on, and the trigger will not fire, since "expression trigger (expression is tested whenever a variable is changed)" according to the help files. Any way to keep these up to date without having a trigger fire every second and slowing the comp waaaaay down? Advance thanks for any help.

(BTW, I know some of it's a bit rough, it's a work in progress. Feel free to give pointers in other areas as well Wink)

*edit - refined the code a bit
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Jun 08, 2004 1:52 pm   
 
You would need a trigger to fire every second and set correctly will not slow your computer down. There are prolly ways to incorp this directly into your code but I just woke up and am still seing double so Ill just nudge you in the right direction.

#ALARM "update" {1} {#IF (@update>=10) {update=0} {#ADD update 1}}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion 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