Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Message
| You can probably do it the complicated way by making a script "on connect" that works out how many minutes to the next hour, then adds a timer that goes off in that many minutes (eg. 23 minutes). That timer calls another script that sets the hourly timer.
However, why not just add 24 one-hour timers, one for each hour of the day? There is no CPU overhead, they just tick away quietly in the background. If you don't want to add them all manually in the dialog box, just open an "immediate" scripting window (Ctrl+I) and enter this ...
World.addtimer "timer1", 0, 0, 0, "", 3, "myscript"
World.addtimer "timer2", 1, 0, 0, "", 3, "myscript"
World.addtimer "timer3", 2, 0, 0, "", 3, "myscript"
World.addtimer "timer4", 3, 0, 0, "", 3, "myscript"
... and so on up to ...
World.addtimer "timer24", 23, 0, 0, "", 3, "myscript"
Each timer calls the same script subroutine "myscript" that does whatever you want to have happen on the hour. Make sure the function "myscript" exists before adding the timers or the add will fail. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|