Dale Innis wrote: Why does it revert to zero? Is the script actually reset, as if an llResetScript() happened? Or are variables set to default values without the script resetting? Or something else?
While others may have a more specific and exacting answer to this, to my understanding a region reset re-starts all scripts (yes, the same as llResetScript). So any data that has not been hard-saved will be lost, just as the contents of volatile RAM is lost when you shut down or restart your computer.
In standard OpenSim, consider a restart working in this way:
On the server screen there is your world on the screen in the form of a text box. This looks like a drop-back to the days of early DOS, but that pitiful-looking text box is what runs your entire world instance, performs teleports, communicates with avatars, etc. Basically... it IS your entire world, known as an "instance" of Opensim code running and doing what it's supposed to do.
When your sim resets or restarts, that instance box shuts down, and ceases to function, disappearing from the screen. It stores some vital information on the hard drive before it shuts off (and some vital information is regularly stored during world operation) but once that program shuts off, *poof*, data is gone, just like any other program that keeps data in RAM rather than a disc database.
So when the instance is turned back on (either by loading an OAR or doing a Kitely World Reset), things start re-building. Objects rebuild, textures are applied to objects, scripts and sound and animations are inserted into proper devices. Some effects carry over as "states" (not to be confused with state() event). For example, particles are maintained, texture animations are maintained, sit positions and other functions are maintained over a reset. Why some things are retained and others not is a mystery of the universe.
However script function is not maintained. They will loose temp variables, accumulated data, and in some instances (if the script is written poorly) will even lose functionality. An example of this is MONEY scripts that rather than being coded to fund and start themselves, instead require the merchant to manually authorize funding. Thus the oft-seen poorly-designed vendors that read "Vendor Offline" because the region restarted and the vendors are waiting for the merchant to manually press the "ON" button.
There is a lot going on during startup.
If you have a script that doesn't have to memorize anything... if it has hard-coded values within the object then such scripts should start working as soon as the world is fully reset. But if it lacks data need to run or requires personal interaction to work... such scripts need modded to work according to standard coding methodology. Ideally a script should never stop working just because a sim resets. However, they will lose any data held in RAM rather than hard-coded and preserved.