How can I add Timers to scripts?

detzX

Active Member
I want to be able to shutoff and logout...I don't want the craft bot running for 8-10 hours so I would like to put a timer(easy enough with comparing times) and then just logout. Any code examples would be great, I would just stick it in the main loop of the scripts I want to use. :D
 

Hendrix

Well-Known Member
the easeist way to do it would be to make a seperate script to handle it... just do something like...
Code:
function main()
{
;This next line will wait for 5 hours
wait 180000

;end the scripts running
endscript Craft

;wait 10 seconds then camp
wait 100
vgexecute /camp
}
 

detzX

Active Member
Beautiful! So I can just make, timer.iss, throw this in there, run it from console and it will work? I'm assuming it's threaded(isx) so it does not hold other scripts back but just kind of rungs in the background?

Also, do I need to end the script..what if I just camp?
 

Hendrix

Well-Known Member
Yes, scripts run independantly and do not effect each other. If you dont end whatever script you are running, and you just camp, it could abort your camp process by trying to move or something.
 

Kannkor

Ogre
Personal preference...
Code:
objectdef timer
{
  variable uint EndTime
 
  method Set(uint Milliseconds)
  {
     EndTime:Set[${Milliseconds}+${Script.RunningTime}]
  }
  member:uint TimeLeft()
  {
     if ${Script.RunningTime}>=${EndTime}
        return 0
     return ${Math.Calc[${EndTime}-${Script.RunningTime}]}
  }
} 

variable timer EggTimer

function main()
{
   EggTimer:Set[1234]
   ;Note: Above time is in ms - so the above is 1.234 seconds
   echo ${EggTimer.TimeLeft}ms remaining
   wait 99999 !${EggTimer.TimeLeft}
   echo Time's up!
}
I can't remember who showed me where this is.. so thank them.. who ever you are...
 
Top Bottom