|
Rastamutti Beginner
Joined: 27 Jun 2012 Posts: 17
|
Posted: Wed May 08, 2013 4:19 pm
%time to number |
Been trying to play with a way to take the %time feature and convert it to a number to compare times..
Example of what I want to physically see.
You stab Bob twice in rapid succession with your dirk.
You have recovered balance. (Recover: 2.16 sec)
So on the stab.. I store the time data... On the recover I take the stab time data and subtract it from the
recovered balance data and show the output. I'm sure this is easy but I just can't figure out the right
commands.
Thanks! |
|
|
|
Rastamutti Beginner
Joined: 27 Jun 2012 Posts: 17
|
Posted: Tue May 21, 2013 8:38 pm |
Hrmm, nobody has any ideas I guess?
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Tue May 21, 2013 10:50 pm |
I am pretty sure that people have discussed time math before, try searching the forums
What do you need the exact time for anyhow? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vaxon Newbie
Joined: 04 Jan 2010 Posts: 5
|
Posted: Sun May 26, 2013 3:14 pm |
I would get time on the first pattern and count it to second:
Code: |
$time_stun = (%time(ss)*1000+%time(zz)) |
On second pattern I would do the same:
Code: |
$time_recover = (%time(ss)*1000+%time(zz)) |
Than substract one from another
Code: |
$time_dif = ($time_recover - $time_now) |
And convert it to something more readable:
Code: |
$second = ($time_dif/1000)
$time_dif = ($time_dif-($second*1000))
$mili = $time_dif
#sub {You have recovered balance. (Recover: %second.$mili sec) |
Hope that helps. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon May 27, 2013 2:44 am |
That is what the built-in function "%secs" is for.
You can use this if you want.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="StopWatch" copy="yes">
<notes>To use the StopWatch just put StopWatchStart into the script where you want to start it. Then put StopWatchStop where you want to stop it and display the time.</notes>
<alias name="StopWatchStart" copy="yes">
<value>stopWatch.StartTime = %secs</value>
</alias>
<alias name="StopWatchStop" copy="yes">
<value>stopWatch.ElapsedTime = (%secs - @stopWatch.StartTime)
$time = (@stopWatch.ElapsedTime / 1000.00)
#print {Elapsed Time: $time s}</value>
</alias>
<var name="stopWatch" type="Record" usedef="true" copy="yes">
<value>StartTime=0|ElapsedTime=0</value>
<json>{"ElapsedTime":0,"StartTime":0}</json>
<default>StartTime=0|ElapsedTime=0</default>
</var>
</class>
</cmud>
|
|
|
|
|
|
|