ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Scrripty on September 17, 2009, 11:21:14 AM
-
I've never messed with calculating time in EUO before. So I'm looking at ways to add some interesting timers to my secondary script menu. There's a 1 second pause in the second script to give the menu a little breathing room, and so it doesn't just rush through, but other than that it's just a loop with a one second pause. What I need to do is something like this I'm guessing:
sub time
set %TimeSpent #scnt - !StartTime
set %Hours ( %TimeSpent / 3600 )
set %Mins ( %TimeSpent / 60 ) - ( %Hours * 60 )
set %Secs ( %TimeSpent -
if %PrevHours <> %Hours
{
set %PrevHours %Hours
menu delete _Hours
menu text _Hours %1 %2 %Hours h
}
if %PrevMins <> %Mins
{
set %PrevMins %Mins
menu delete _Mins
menu text _Mins %3 %4 %Mins m
}
if #PrevSecs <> %Secs
{
set %PrevSecs %Secs
menu delete _Secs
menu text _Secs %5 %6 %Secs s
}
RETURN
I'm just having a hard time figuring out how I should use this info to calulate different stats for things in the menu/main script. And coming up with a way to calc seconds on the menu. A good way that is. TM your idea gave me an idea on a WAY to cal seconds... but it wouldn't give me a good way to use it calc real time. It would just keep track of 60 second intervals... that's not really what I want. :/ You're right.
-
Here's one that I wrote that does all the magic for you:
;-------------------------------------------------------------------------------
; %1 = input - Time to convert
; #RESULT - Time converted to #:##:## format
sub TM_ConvertTimeHourMinSec
namespace push
namespace local ctime
set !hourpart %1 / 3600
set !secpart ( %1 % 3600 ) % 60
set !minpart ( ( %1 % 3600 ) / 60 )
if !hourpart >= 10
set #RESULT !hourpart , :
else
set #RESULT 0 , !hourpart , :
if !minpart < 10
set #RESULT #RESULT , 0
set #RESULT #RESULT , !minpart , :
if !secpart < 10
set #RESULT #RESULT , 0
set #RESULT #RESULT , !secpart
namespace pop
return #RESULT
So at the beginning of the script, I make a note of the time %online_start_time
set !temp #SCNT - %online_start_time
gosub TM_ConvertTimeHourMinSec !temp ; time in H:MM:SS returned in #RESULT
What I typically do is have another counter that I use to update the display. 2, 3, 5, 10 seconds. Whatever. But you just monitor this counter to determine when you should call the above code and update the display.
-
Yea, I can do that with someones sub like yours, but what I'm trying to do, is calculate things like, length of time evade has been up. That's actually pretty easy. I can just take the amount of seconds it set for in the script, and multiply that by the number of casts on the menu I guess. That's easy. But what if I want to calculate something more difficult? I'm already thinking of easier ways to do this actually just by fudging a bit and not using the ACTUAL times using the info I already have to come up with the "average" times I guess. I was looking for ways to have the ACTUAL time for things tho.