ID:178796
 
Can anyone point me to any articles or examples on understanding and coding timers? The specific thing I want to attempt is to time how long it takes a player to complete a task. In other words once a verb is clicked to pick up an item a timer starts ,the player can then go about thier buisness if they wish, the goal is to get the item to a destination as quickly as possible. When they reach the dest I want to be able to determine how long it took to get there.

I am not looking for code to do this as much as an information to help me understand how to use and code them.

Thanks in advance for you help
-Shwn
Shwn wrote:
I am not looking for code to do this as much as an information to help me understand how to use and code them.

As I can see, you aren't just a newbie begging for "codes".

The best way to go about doing this is making a proc, and a var called time. Then, once the task is executed, call the proc. Have the proc add 1 to it every second (sleep(10)). Then, once they have finished the task, just display the var that you have been adding to.

Hope I helped

-Rcet
In response to Rcet
Well I would fall into the newbie catagory for sure. However I come from the philosophy of give a man "a code" and he fixes one problem, help him understand the concept and he codes for ever. Here is what is unclear to me about timers.

When you start a timer how do you tell the timer to stop timing and return the elapsed time?
In response to Shwn
Here's a small example:

var/timer = 100 // Creates global time var

proc/timer()
while(timer != 0)// While the timer var isn't 0
sleep(10)//delays a tick
timer--//subtracts one from timer
return timer //returns the timer var

mob
Stat()
..()
statpanel("Timer")
stat("Timer",timer())//Shows what the timer proc returns in a stat panel


Hope that helps you learn a bit.