ArchTx Edo Posted August 24, 2012 Share Posted August 24, 2012 I know how to use llSetTimerEvent(float sec) to trigger an event by counting down to it. But is there a way to start that countdown on a specific date, such as the first day of each month? What I really want to do is send out a message and/or notecard on the first day of each month. Link to comment Share on other sites More sharing options...
Talia Davidov Posted August 24, 2012 Share Posted August 24, 2012 Others can correct me, but I don't believe there is anyway to trigger a script on a specific date. However, you can use the llSetTimerEvent to trigger once and day and then use llGetDate to filter out whether or not it is the first day of the month. default{ state_entry() { llSetTimerEvent(86400); } timer() { string strDate = llGetDate(); if (llGetSubString(strDate,8,9) == "01") { // send note card } }} ETA: I can not get inworld to check the code to make sure it works, it is just an example of the logic Link to comment Share on other sites More sharing options...
Ela Talaj Posted August 24, 2012 Share Posted August 24, 2012 You're correct in principle but it is not as simple as it seems. Firstly a daily timer (86400) would introduce an increasing time deviation due to dilation which in a month or so may become quite significant. Experience shows that an hourly timer with dilation correction works the best. Secondly must have adjustment for sim being offline. Thirdly, both the llGetDate() and llGetTimestamp() return zulu time zone (UTC) so got to convert to a desired timezone because what's the 1st of the month in UTC is still last day of the previous month in for instance Pacific or may be already 2nd of the month in the Far East. I personally would've used unix time via llGetUnixTime() and convert to date from there (there are algorithms for unix time to a date in a specific timezone conversion on the web). All considered more than just a few lines of code may be required. Link to comment Share on other sites More sharing options...
Talia Davidov Posted August 25, 2012 Share Posted August 25, 2012 It depends on the precision needed. If you just want to send something out around the first of the month then I disagree. It is a simple script. If you need to be sure to send it the exact second your exact location is the first of the month then you are correct. However, since the grid has global users that seems irrelevant to me. You might have people from every time zone for you list. Needless complication is not always good when the script doesn't need it. It all depends on the specific needs of the OP which where generally stated. As I said it was an example of concept of idea. Why use the extra processing to calculate the date from llGetUnixTime when llGetDate already tells you if it is the first or not? Once again its a matter of precision that for something done once a month is probably irrelevant. All considering more than a few lines may not be required. It just depends on the precision needed. ETA I do agree with Ela adding code to handle sim outages is important in a final script Link to comment Share on other sites More sharing options...
Nova Convair Posted August 25, 2012 Share Posted August 25, 2012 float offset = 3600.0 * 6.0; llSetTimerEvent( 86400.0 - llGetWallClock() +offset); The llSetTimerEvent belongs into the timer event and will trigger the next event at 6 am PST on the next day. That will correct time dilations daily. Link to comment Share on other sites More sharing options...
ArchTx Edo Posted August 25, 2012 Author Share Posted August 25, 2012 Thanks everyone. I don't need a high degree of precision for my purposes. I appreciate the suggestions on how to do this. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now