Resetting Scripts in a Large Build
If you have a complex build, perhaps sim wide and you need to reset all of the scripts, there isn't an easy way to do this, say from from parcel properties or the region tools.
This presents a few startegies for providing this ability but it does require some forethought.
Region Restart
Detect region restart and restart script.
(or other event)
<lsl>
default { state_entry() { //setup and do stuff }
changed(integer change) { if (change & CHANGED_REGION_START) { llOwnerSay("The regions has just restarted, resetting the script."); llResetScript(); } } }
</lsl>
Listener - restart on command
Listen for instruction and restart script.
<lsl>
default {
// this script sends the command to reset the other scripts to reset. // change to use any trigger event that is suitable.
integer channel = -1324628; // some random negative number string command = "reset"; // could consider using a random string for the command to obscure the function
touch(integer num_detected) { llRegionsSay(channel, command); // (3) }
}
</lsl>
<lsl>
default {
//insert the lisetn into your scripts that need to reset on command
integer channel = -1324628; //some random negative number string command = "reset"; //could consider using a random string for the command to obscure the function
state_entry() { //setup and do stuff llListen(channel, "", NULL_KEY, command); }
listen(integer channel, string name, key id, string message) { if (message == command) llResetScript(); }
}
</lsl>
Random Staggered Reset
Script load on the sim may be a concern, if so you could use a random timer in the target script to stagger the reset as follows:
<lsl>
default {
//insert the listen into your scripts that need to reset on command
integer channel = -1324628; //some random negative number string command = "reset"; //could consider using a random string for the command to obscure the function
state_entry() { //setup and do stuff llListen(channel, "", NULL_KEY, command); }
listen(integer channel, string name, key id, string message) { if (message == command) llSetTimer(llFrand(60)); //random timer within 60 seconds }
timer() { llResetScript(); }
}
</lsl>
If you need to stagger the resets, perhaps because the order the sxripts start is imortant, use different commands with appropriate pauses between start commands, such as:
<lsl>
default {
integer channel = -1324628; //some random negative number string command = "reset3"; //could consider using a random string for the command to obscure the function. "reset3" will trigger after 15 seconds.
state_entry() { //setup and do stuff llListen(channel, "", NULL_KEY, command); }
listen(integer channel, string name, key id, string message) { if (message == command) llResetScript(); }
}
</lsl>
Return to Good_Building_Practices