Difference between revisions of "Resetting Scripts in a Large Build"
Myopic Mole (talk | contribs) (first draft) |
Kireji Haiku (talk | contribs) m (fixed a few typos in the scripts and reformatted to improve readbility) |
||
Line 10: | Line 10: | ||
<lsl> | <lsl> | ||
default | default | ||
{ | { | ||
changed(integer change) | |||
{ | |||
if (change & CHANGED_REGION_START) | |||
{ | |||
llOwnerSay("The regions has just restarted, resetting the script."); | |||
llResetScript(); | |||
} | |||
} | |||
state_entry() | |||
{ | |||
// setup and do stuff | |||
; | |||
} | |||
} | } | ||
</lsl> | </lsl> | ||
Line 35: | Line 34: | ||
<lsl> | <lsl> | ||
// some random negative number | |||
integer chatChannel = -1324628; | |||
// could consider using a random string for the command to obscure the function | |||
string chatCommand = "reset"; | |||
default | default | ||
{ | { | ||
// this script sends the command to reset the other scripts to reset. | |||
// change to use any trigger event that is suitable. | |||
touch(integer num_detected) | |||
{ | |||
llRegionSay(chatChannel, chatCommand);// (3) | |||
} | |||
} | } | ||
</lsl> | </lsl> | ||
<lsl> | <lsl> | ||
// some random negative number | |||
integer chatChannel = -1324628; | |||
// could consider using a random string for the command to obscure the function | |||
string chatCommand = "reset"; | |||
default | default | ||
{ | { | ||
// insert the listen into your scripts that need to reset on command | |||
state_entry() | |||
{ | |||
// setup and do stuff | |||
llListen(chatChannel, "", NULL_KEY, chatCommand); | |||
} | |||
listen(integer channel, string name, key id, string message) | |||
{ | |||
if (message == chatCommand) | |||
llResetScript(); | |||
} | |||
} | } | ||
</lsl> | </lsl> | ||
Line 84: | Line 82: | ||
<lsl> | <lsl> | ||
// some random negative number | |||
integer chatChannel = -1324628; | |||
// could consider using a random string for the command to obscure the function | |||
string chatCommand = "reset"; | |||
default | default | ||
{ | { | ||
// insert the listen into your scripts that need to reset on command | |||
state_entry() | |||
{ | |||
// setup and do stuff | |||
llListen(chatChannel, "", NULL_KEY, chatCommand); | |||
} | |||
listen(integer channel, string name, key id, string message) | |||
{ | |||
if (message == chatCommand) | |||
// { | |||
// random timer within [0.0, 60.0) | |||
llSetTimerEvent( llFrand(60.0) ); | |||
// } | |||
} | |||
timer() | |||
{ | |||
llResetScript(); | |||
} | |||
} | } | ||
</lsl> | </lsl> | ||
Line 117: | Line 118: | ||
<lsl> | <lsl> | ||
// some random negative number | |||
integer chatChannel = -1324628; | |||
// could consider using a random string for the command to obscure the function. "reset3" will trigger after 15 seconds. | |||
string chatCommand = "reset3"; | |||
default | default | ||
{ | { | ||
state_entry() | |||
{ | |||
// setup and do stuff | |||
llListen(chatChannel, "", NULL_KEY, chatCommand); | |||
} | |||
listen(integer channel, string name, key id, string message) | |||
{ | |||
if (message == chatCommand) | |||
llResetScript(); | |||
} | |||
} | } | ||
</lsl> | </lsl> | ||
---- | ---- | ||
Return to [[Good_Building_Practices]] | Return to [[Good_Building_Practices]] |
Revision as of 12:35, 31 October 2012
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 {
changed(integer change) { if (change & CHANGED_REGION_START) { llOwnerSay("The regions has just restarted, resetting the script."); llResetScript(); } }
state_entry() { // setup and do stuff ; }
} </lsl>
Listener - restart on command
Listen for instruction and restart script.
<lsl> // some random negative number integer chatChannel = -1324628;
// could consider using a random string for the command to obscure the function string chatCommand = "reset";
default { // this script sends the command to reset the other scripts to reset. // change to use any trigger event that is suitable.
touch(integer num_detected) { llRegionSay(chatChannel, chatCommand);// (3) }
} </lsl>
<lsl> // some random negative number integer chatChannel = -1324628;
// could consider using a random string for the command to obscure the function string chatCommand = "reset";
default { // insert the listen into your scripts that need to reset on command
state_entry() { // setup and do stuff llListen(chatChannel, "", NULL_KEY, chatCommand); }
listen(integer channel, string name, key id, string message) { if (message == chatCommand) 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> // some random negative number integer chatChannel = -1324628;
// could consider using a random string for the command to obscure the function string chatCommand = "reset";
default { // insert the listen into your scripts that need to reset on command
state_entry() { // setup and do stuff llListen(chatChannel, "", NULL_KEY, chatCommand); }
listen(integer channel, string name, key id, string message) { if (message == chatCommand)
// {
// random timer within [0.0, 60.0) llSetTimerEvent( llFrand(60.0) );
// }
}
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> // some random negative number integer chatChannel = -1324628;
// could consider using a random string for the command to obscure the function. "reset3" will trigger after 15 seconds. string chatCommand = "reset3";
default {
state_entry() { // setup and do stuff llListen(chatChannel, "", NULL_KEY, chatCommand); }
listen(integer channel, string name, key id, string message) { if (message == chatCommand) llResetScript(); }
} </lsl>
Return to Good_Building_Practices