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
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sat Aug 17, 2002 9:10 am   

Pausing Rate Tracker
 
I have a set that tracks how much exp I make over time, using %secs to time it. I'm looking for an effective way to pause the rate timer, and resume it whenever I want. Here's the code:

#ALIAS rate
rate_check = %eval( %secs / 1000)
#if (@rate_check < @rate_start) {rate_check = %eval( @rate_check + 86400)}
rate_mins = %eval( (@rate_check - @rate_start) / 60)
rate_norm = %eval( @rate_exp / ((@rate_check - @rate_start) / 60))
#var rate_k %eval( %float( @rate_exp) / (%float( (@rate_check - @rate_start) / 60)) / 1000)
#say -=EXP RATE=- Since @rate_starttime
#say ------------------------------------------
#say Exp Gained - @rate_exp
#say Minutes - @rate_mins
#say Rate - @rate_norm ~{%format( 0, @rate_k)k/min~}}

I also have an alias that resets all the vars and sets the @rate_start and @rate_starttime values.

Any ideas how I could make an alias to pause/resume this?

Fat Tony
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 17, 2002 9:49 am   
 
#AL pause
rate_pause = %secs

#AL resume
rate_start = %eval( (@rate_start + ((%secs - @rate_pause) / 1000) + 864000) 86400)

LightBulb
Senior Member
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sat Aug 17, 2002 6:30 pm   
 
Well that works to pause it, but when I resume, it adds in all the time it was paused. For example, if I pause at 574 mins, the timer will stay at 574 mins. Wait half an hour, and resume, and the timer now displayes 604 mins, instead of 574.

There is also a trigger off of my prompt that tracks the exp gain. Here's the code:

#trigger %1Hp %2Sp %3Xp %4Kg>
st_exp = %3
#if (@last_exp != %3) {
rate_expcount = %eval( %3 - @last_exp)
#add rate_exp @rate_expcount
#add ratet_exp @rate_expcount
#say Experience Gained: @rate_expcount
}
last_exp = @st_exp
rate_check = %eval( %secs / 1000)
#if (@rate_check < @rate_start) {rate_check = %eval( @rate_check + 86400)}
#var rate_k %eval( %float( @rate_exp) / (%float( (@rate_check - @rate_start) / 60)) / 1000)
rate_mins = %eval( (@rate_check - @rate_start) / 60)

I added a #t- command in the rate_pause variable to disable that trigger, and a #t+ to resume it. Here's the code for those:

#alias pause_rate
rate_pause = %eval( %secs / 1000)
rate_pauseflag = 1
#t- RatePrompt

#alias resume_rate
rate_start = %eval( (@rate_start + ((%secs / 1000) - @rate_pause) + 864000) / 86400)
rate_pauseflag = 0
#t+ RatePrompt

And here's the edited rate alias

#alias rate
#if (@rate_pauseflag = 0) {
rate_check = %eval( %secs / 1000)
#if (@rate_check < @rate_start) {rate_check = %eval( @rate_check + 86400)}
rate_mins = %eval( (@rate_check - @rate_start) / 60)
rate_norm = %eval( @rate_exp / ((@rate_check - @rate_start) / 60))
#var rate_k %eval( %float( @rate_exp) / (%float( (@rate_check - @rate_start) / 60)) / 1000)
#say -=EXP RATE=- Since @rate_starttime
#say ------------------------------------------
#say Exp Gained - @rate_exp
#say Minutes - @rate_mins
#say Rate - @rate_norm ~{%format( 0, @rate_k)k/min~}
}


Ohhkay. If possible though, I need to be able to pause the exp tracking AND timer, so that when I resume I'm exactly where I left off. (In case a phone rings or something comes up, etc.)

Thanks for all your help.

Fat Tony
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sat Aug 17, 2002 6:44 pm   
 
I think I solved the problem. You had the resume alias like this:

rate_start = %eval( (@rate_start + ((%secs - @rate_pause) / 1000) + 864000) 86400)

I had switched the at the end to a regular /. Switching it back fixed the tracker (newbie mistake). Though it did give me a syntax error that wasn't there with the /.

Thanks Lightbulb!

Fat Tony
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