Timing framework

Share your scripts and packages with other Mudlet users.
Post Reply
naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Timing framework

Post by naftali »

I wanted to figure out balance times and such for many things, so I whipped up something that let me easily create timers, collect multiple times for a repeating event, and store and organize these times.

Usage:

timerOn( "name" )

Starts a timer (creating one if necessary, using an old one if not) called "name". Also stores a time and restarts the timer if that timer is already running, so it can be used for events that happen regularly like passive healing or denizen attacks.

timerOff( "name" )

Stops that timer, records the time in a table. All other times from timers with the same name will be stored in the same table. timerAvg, timerMed, timerMax, and timerMin("name") all give the corresponding statistic (Mean average, median, max, min) for each set of times. You can also get a list of all the times you've gathered in btimes.stats["name"]

So 2 examples for the 2 basic uses:
Example 1:
You kick out at - trigger that calls timerOn( "kick" )
You have regained balance on all limbs. - trigger that calls timerOff("kick")

Now every time you kick something it will gather data on how long it takes to regain balance. Note if you're looking for accurate times you probably wanna use this in controlled circumstances since it can't compensate for things like being thrown further off balance in the middle of an attack.

Example 2:
Rob cuts you viciously with his sword - trigger that calls triggerOn("robattack")

that's all you technically need, although when Rob stops attacking (because he's dead or you've run away) the timer will keep going in a not-so-healthy way, so you either want to remember to call timerReset() somehow (I need to remember to work that into the alias soon) or make a trigger like this:

You have slain Rob. - trigger that calls timerAbort("robattack")

That's about it! Feel free to ask questions, critique the idea, suggest features, or tell me how I'm making something overly complicated.
Attachments
Timing Framework.xml
(6.95 KiB) Downloaded 534 times

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Timing framework

Post by Vadi »

That looks real nice, will give it a look.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Timing framework

Post by Vadi »

Just to add to this, there is also a timerReport("timer") function, and timerInit should be called somewhere at the start.

Post Reply