I am writing a script and i want something to happen at midnight every day
So how do i make an event happen at 12 am SL time every day?
These forums are CLOSED. Please visit the new forums HERE
an event at midnight |
|
|
Rocketman Raymaker
Registered User
Join date: 4 Feb 2007
Posts: 530
|
05-15-2007 00:45
I am writing a script and i want something to happen at midnight every day
So how do i make an event happen at 12 am SL time every day? _____________________
"Proud member of the anti-ginko busy body committee"
|
|
Ace Albion
Registered User
Join date: 21 Oct 2005
Posts: 866
|
05-15-2007 01:05
_____________________
Ace's Spaces! at Deco (147, 148, 24)
ace.5pointstudio.com |
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
05-15-2007 01:46
You may also want to look at http://wiki.secondlife.com/wiki/LlSetTimerEvent or http://wiki.secondlife.com/wiki/LlSleep _____________________
I'm back......
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-15-2007 02:09
dont forget your math
if i were to do it ... when the script came online check the time, and get the difference tween then and midnight set a sleep, or a timer (timer if you want the script to do things while its waiting) for the difference tween the time and the next whole hour (ie you start it up at 11:30 am set a 30 min event) after that check every hour and ajust for differences untill you hit midnight |
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-15-2007 10:03
Why check every hour?
Surely one line should do it: CODE llSleep(86400 - llGetWallclock()); llGetWallclock returns the seconds since midnight. 24 hours is 86400 seconds, so the above makes it sleep for the number of seconds till the next midnight. To make it repeat each day, simply put that line in a function that calls itself. _____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
05-15-2007 11:47
Why check every hour? Surely one line should do it: CODE llSleep(86400 - llGetWallclock()); llGetWallclock returns the seconds since midnight. 24 hours is 86400 seconds, so the above makes it sleep for the number of seconds till the next midnight. To make it repeat each day, simply put that line in a function that calls itself. I wonder how much time drift there would be over a 24 hour period if any. |
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-15-2007 20:07
Why check every hour? Surely one line should do it: CODE llSleep(86400 - llGetWallclock()); llGetWallclock returns the seconds since midnight. 24 hours is 86400 seconds, so the above makes it sleep for the number of seconds till the next midnight. To make it repeat each day, simply put that line in a function that calls itself. becuase in a day the timer event drifts becuase of script lag becuase of downtimes and updates it wont strike midnight if the server has been down slow ect as far as the actuall drift, its hard to nail down .. on my home sim it can get upto 10 min in a day, out by my shop its within seconds couse get a botched update or a grey goo attack it could be hours ... |
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-16-2007 00:58
Is that specific to the timer event or does it also effect the sleep?
I haven't tested for drift, so I don't know. Might be interesting to find out what happens to sleeping scripts on a sim reset as well. _____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|
|
Korwyn Obscure
Registered User
Join date: 25 Jan 2007
Posts: 31
|
05-16-2007 07:23
Why not just verify that llGetWallClock= somewhere between 0 and 30 (in seconds) and then do the event?
Means it'll do the event every time at midnight SLT. |
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-16-2007 20:11
Is that specific to the timer event or does it also effect the sleep? I haven't tested for drift, so I don't know. Might be interesting to find out what happens to sleeping scripts on a sim reset as well. far as i can tell (which i havent spent my life on this or anything) timer and sleep use the same thing for the countdown |
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-16-2007 20:14
Why not just verify that llGetWallClock= somewhere between 0 and 30 (in seconds) and then do the event? Means it'll do the event every time at midnight SLT. 0 seconds will shut the timer off and checking it every 30 seconds means it would check 2880 times a day every hour or 2 and doing some basic math would give pretty pinpoint results |
|
Stavros Augustus
Registered User
Join date: 14 Nov 2005
Posts: 38
|
05-16-2007 20:50
0 seconds will shut the timer off and checking it every 30 seconds means it would check 2880 times a day every hour or 2 and doing some basic math would give pretty pinpoint results That's not what he means at all. He means: CODE if(llGetWallClock > 0 || llGetWallClock < 30) { |
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
05-16-2007 21:54
Or you can just get the sun direction, with a little fudging on the <0, 0, -1> giving yourself a little buffer so you aren't firing the timer event and checking every second, and here is the link to the function at one of the wikis.
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llgetsundirection |