|
kingv24 Newbie
Joined: 08 Apr 2005 Posts: 4
|
Posted: Wed Oct 27, 2010 9:26 pm
Help with a running timer for an xp counter |
Sorry if this has been posted before, I can't find it.
For the counter I have:
#CLASS {xpcounter}
#ALIAS ResetSession {#var XPCount 0} "xpcounter"
#VAR XPCount {0} {0} "xpcounter"
#TRIGGER {You receive (%d) experience points.} {#add XPCount %1} "xpcounter"
#BUTTON 1 {resetxp} {resetsession;#echo Count reset.} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} "xpcounter" {} {} {}
#BUTTON 2 {xpcount} {#echo You have gained @xpcount exp.} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} "xpcounter" {} {} {}
This works fine. Is there a way to keep track of time gaining this xp? I'd like to be able to display the time and xp and reset both with the buttons if it's possible. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Oct 27, 2010 11:23 pm |
If you want just want to show the start and stop time, you can easily do that via the %time() function. Just assign it to a variable, and then where necessary put it up for display.
If you want to calculate the time delta (difference) between start and stop, you will need to divide each time value into the individual hours, minutes, and seconds, handle all of the math necessary to deal with each component, and then reconvert that end value back into hours, minutes, and seconds. It's really just simple math, but there's no time-math functions in ZMud that allow you to run math on hh:nn:ss values directly. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Thu Oct 28, 2010 1:11 am |
It's a little bit easier to calculate elapsed time under 24 hours if you use the %secs predefined variable instead of %time(). %secs returns the number of miliseconds that have elapsed since midnight.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Oct 28, 2010 2:04 am |
Actually, %secs returns the amount of time since CMud was last opened rather than since midnight.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Thu Oct 28, 2010 2:43 am |
This is the zMud section of the forum. %secs works differently between the two clients. In zMud it returns the number of miliseconds that have elapsed since midnight
|
|
|
|
|
|