View unanswered posts | View active topics It is currently Sun Apr 19, 2026 9:11 pm



Reply to topic  [ 6 posts ] 
 TIME AND TIMERS 
Author Message
Gameop
User avatar

Joined: Mon Jan 26, 2009 12:27 am
Posts: 123
Unread post TIME AND TIMERS
Hi to all TW scripters,

I would like to generate a timer to know how long my script is running.

Code:
SETVAR $STEP1 TIME
SETVAR $STEP11 TIME
SETVAR $TotalTime $STEP11
SUBTRACT $TotalTime $STEP1

ECHO $TotalTime

I tried that but, I got an error : Script run-time error in 'SO_STARWARSMOD_MAIN(B-5).TS': '13:22:51' is not a decimal number, line 139

So I know that my subtract command is my line 139 and that it's the problem of it's not a decimal number...
So there is a command that I can use to count the time between the start time for my script ($STEP1) and my final time ($STEP11)
?? Each of my step is written in a Text file and give me the time of starting and ending of each step. But I would be able to have the total time of my running script without count it myself.

Thanks you. It's my last problem with my big script that generate my SW edit.

_________________
Dodger known as Yop Solo, Sysop
twgsdodgerbbs.ath.cx
http://cyberquebec.ca/_layout/?uri=http://cyberquebec.ca/twgsdodgerbbs/


Wed Jan 20, 2010 1:36 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: TIME AND TIMERS
getTimer

It's tick-based. Just divide by your avg ticks per second to derive seconds.

getTime returns a standard notation, and while that works you do have to covert it to seconds past epoch before you can do anything.

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Wed Jan 20, 2010 1:49 pm
Profile ICQ WWW
Gameop
User avatar

Joined: Mon Jan 26, 2009 12:27 am
Posts: 123
Unread post Re: TIME AND TIMERS
Ok i will read on getTimer, i'm not familar on how to use it.
If you have and example to help me, it will be nice to understand what you wrote to explain me.

_________________
Dodger known as Yop Solo, Sysop
twgsdodgerbbs.ath.cx
http://cyberquebec.ca/_layout/?uri=http://cyberquebec.ca/twgsdodgerbbs/


Wed Jan 20, 2010 1:52 pm
Profile
Commander
User avatar

Joined: Wed May 03, 2006 2:00 am
Posts: 1722
Location: USA
Unread post Re: TIME AND TIMERS
Yop wrote:
Hi to all TW scripters,
I would like to generate a timer to know how long my script is running.
Code:
SETVAR $STEP1 TIME
SETVAR $STEP11 TIME
SETVAR $TotalTime $STEP11
SUBTRACT $TotalTime $STEP1




Code:
gettime $first_time_stamp "h:n:s am/pm"
replacetext $first_time_stamp ":" " "
getword $first_time_stamp $hour0 1
getword $first_time_stamp $min0 2
getword $first_time_stamp $sec0 3
getword $first_time_stamp $stamp0 4
striptext $first_time_stamp "am"
striptext $first_time_stamp "pm"
#echo "*" $hour0 "*" $min0 "*" $sec0 "*" $stamp0 "*"
setvar $first_total_second (($hour0*3600)+($min0*60)+$sec0)

#run script here
#setdelaytrigger one :one 5000
#pause
#:one

gettime $last_time_stamp "h:n:s am/pm"
replacetext $last_time_stamp ":" " "
getword $last_time_stamp $hour1 1
getword $last_time_stamp $min1 2
getword $last_time_stamp $sec1 3
getword $last_time_stamp $stamp1 4
striptext $last_time_stamp "am"
striptext $last_time_stamp "pm"
#echo "*" $hour1 "*" $min1 "*" $sec1 "*" $stamp1 "*"
setvar $last_total_second (($hour1*3600)+($min1*60)+$sec1)

setprecision 0
if ($stamp0 = $stamp1)
setvar $script_run_time_sec ($last_total_second - $first_total_second)
else
setvar $script_run_time_sec (($last_total_second + 43200) - $first_total_second)
end

setprecision 1
setvar $script_run_hours ($script_run_time_sec/3600)
if ($script_run_hours > 1)
setvar $script_run_time_sec (($script_run_hours*3600)-$script_run_time_sec)
end
round $script_run_hours 0

setprecision 1
setvar $script_run_min ($script_run_time_sec/60)
if ($script_run_min < 1)
setvar $script_run_min 0
else
setvar $script_run_time_sec (($script_run_min*60)-$script_run_time_sec)
end
round $script_run_min 0
setprecision 0
echo ANSI_14 "SCRIPT TOOK " $script_run_hours & " Hours " & $script_run_min & " Minutes " & $script_run_time_sec & " Seconds to run*"







As long as you dont go past 12 hours run time this will work i think

cela ne fait rien

_________________
Coconut Telegraph (ICQ)#586137616
Team Speak3@ 220.244.125.70:9987
Founding Member -=[Team Kraaken]=- Winner of Gridwars 2010 - Ka Pla
Image
Jesus wounldn't Subspace Crawl


Wed Jan 20, 2010 4:16 pm
Profile ICQ YIM
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: TIME AND TIMERS
The best approach will depend on how long you expect the script to run. If it is something that is going to run for a few seconds, then getTimer will give very accurate results. If it will run for more than a few seconds, then you probably want to use getTime, and specify your own format. getTime takes formats based on Delphi's DateTimeToString command, so look up that command for more specifics. A few common formats might be:
getTime $hour "h"
getTime $minute "n"
getTime $second "s"
echo "*Duration: " ((($hour * 3600) + ($minute * 60)) + $second) " Seconds.*"

Using this as a starting point, you should be able to manipulate and display the time lapse however you like.

Good luck,
+EP+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Wed Jan 20, 2010 8:38 pm
Profile WWW
Staff Sergeant

Joined: Mon May 25, 2009 6:38 pm
Posts: 19
Unread post Re: TIME AND TIMERS
Also, you can use the (undocumented) millisecond timer. "zzz"

Code:

getTime $starttime "s:zzz"
striptext $starttime ":"

getTime $endtime "s:zzz"
striptext $endtime ":"
setvar $pingtime (($endtime - $starttime) / 2)



Useful if you want to compensate for lag. You would, of course have to add the rest of the ping script to get a real ping time, I included only the part that is undocumented, for the sake of clarity. My ping script is, I'm told very similar to ProPing, but having no source code for ProPing, I cannot say.


Tue Feb 23, 2010 2:50 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.