Thanks for all of this! That pretty much agrees with my own experience.
To make my specific remaining question more concrete, consider this (very artificial) example:
Code: Select all
default {
state_entry() {
llSetTimerEvent(30.0 + llFrand(30.0)); // Wait for 30-60 seconds
}
timer() {
llSetTimerEvent(0.0); // Turn off timer for now
integer i;
for (i=0; i < 20; i++) { // Count up to 20, slowly
llSay(0, (string)i);
llSleep(1.0);
}
llSetTimerEvent(30.0 + llFrand(30.0)); // Wait for 30-60 seconds
}
} // default
The thing that I don't know is what happens if the sim is shut down during the roughly 20 seconds that the script spends in the timer() event, counting slowly up to 20 (with one-second sleeps in between). Obviously this isn't something that it makes much sense to do

but the general question is "what happens if the sim shuts down while in an event handler?".
In this case, let's say the sim shuts down when the script is sleeping after saying "11". Later it's restarted, so what happens?
The four possibilities that I can think of are:
1) The sim will in fact not shut down until all scripts have either returned from the current handler, or gotten reset due to the event time limit (which is I think 30 seconds); in this case the sim will keep running for another 9 seconds, the script will count all the way to 19 and then set a new timer event value and return from the handler. Then the sim would actually shut down, and then it's restarted the script will wait a few seconds and then start counting from 0 again.
2) The entire state of the script, including exactly what it was doing and what all values were, is saved and restored. In this case, it will say "11", the sim will be shut down, and then when the sim comes back up again it will say "12", "13", etc.
3) The fact that it was in the handler is saved and restored, but not where it was. In this case, when the sim is restarted it will start back at saying "0" again, count up to "19", set a new timer event, and all will be well.
4) The fact that it was in the handler isn't saved and restored, in which case since there was no timer event currently scheduled, once the sim is started back up the script will never say anything again, until something else (probably manual intervention) resets the script (losing any internal data, etc).
I have seen a few things that make me think that the case might be (4), but I'd love to see the actual code.
(If the case is (4), this should be made clear to people somewhere, and the right fix is just not to do the llSetTimerEvent(0.0) at the start of the timer() handler in this case, and generally to make sure that if a handler exits unexpectedly, other handlers will eventually fire and get things going again.)
Hope that all makes sense! I can't think of a great way to test this offhand, as it would be hard to get all the timings and observations just right.