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
Gylen
Newbie


Joined: 20 Nov 2003
Posts: 3

PostPosted: Thu Nov 20, 2003 4:35 pm   

Duration timer for buffs (output formating)
 
I have a many trigers setup as below, basicly one for each buff type.

#CLASS {prot-Unstun}
#TRIGGER {chanting appears to do absolutely nothing.} {
#var unstuntime %ctime
party say Unstun Active.
#if !%ismember( Us, @prots) {#var prots %additem( Us, @prots)}
}
#TRIGGER {^It doesn't hurt} {
party say Unstun Expired. Lasted %eval( (%ctime-@unstuntime)) seconds.
#var unstuntime {0} {0}
#var prots %delitem( Us, @prots)
}
#CLASS 0

It works great, except I would like to format the output in HH:MM:SS.
Anyone know how to accomplish this?

Current output:
Unstun Expired. Lasted 200 seconds.

Wanted output:
Unstun Expired. Lasted [0h:12m:3s].
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Nov 20, 2003 6:44 pm   
 
Just do the math.

Hours is seconds divided by 3600. ((%ctime - @unstuntime) / 3600)
Minutes is (remaining) seconds divided by 60. The remainder after accounting for hours can be found using modulus division. (((%ctime - @unstuntime) 3600) / 60)
Seconds is the remainder after accounting for minutes. This can also be determined with modulus division. ((%ctime - @unstuntime) 60)
Reply with quote
Gylen
Newbie


Joined: 20 Nov 2003
Posts: 3

PostPosted: Thu Nov 20, 2003 9:27 pm   
 
#CLASS {prot-Unstun}
#TRIGGER {chanting appears to do absolutely nothing.} {
#var unstuntime %ctime
party say Unstun Active.
#if !%ismember( Us, @prots) {#var prots %additem( Us, @prots)}
}
#TRIGGER {{^It doesn't hurt} {
party say Unstun Expires. Lasted %eval((%ctime - @unstuntime) / 3600)h:%eval(((%ctime - @unstuntime) 3600) / 60)m:%eval ((%ctime - @unstuntime) 60)s
#var unstuntime {0} {0}
#var prots %delitem( Us, @prots)
}
#CLASS 0

It gives me a syntax error at the first modulus divison:
h:%eval(((%ctime - @unstuntime) 3600) / 60)
~~~~~~~~~~~~~~~~~~~~~^ syntax error
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Nov 20, 2003 11:34 pm   
 
You can ignore this particular syntax error, it has appeared in every version since 6.16. Just never been fixed totally. If want it to go away you can use the %mod function instead of the mod () operator.
Reply with quote
Gylen
Newbie


Joined: 20 Nov 2003
Posts: 3

PostPosted: Fri Nov 21, 2003 2:21 am   
 
Thank you for the help.
In case anyone else is looking for a simular trig:

#CLASS {prot-Unstun}
#TRIGGER {chanting appears to do absolutely nothing.} {
#var unstuntime %ctime
party say Unstun Active.
#if !%ismember( Us, @prots) {#var prots %additem( Us, @prots)}
}
#TRIGGER {^It doesn't hurt} {
party say Unstun Expires. %eval( (%ctime - @unstuntime)/3600)h:%mod( ((%ctime - @unstuntime))/60, 60)m:%mod( (%ctime - @unstuntime), 60)s
#var unstuntime {0} {0}
#var prots %delitem( Us, @prots)
}
#CLASS 0


Output is : Unstun Expires. 0h:8m:58s
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