Jump to content

Can a date trigger an event?


ArchTx Edo
 Share

You are about to reply to a thread that has been inactive for 4300 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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

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

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

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

You are about to reply to a thread that has been inactive for 4300 days.

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
 Share

×
×
  • Create New...