|
Comment
|
[ Here's some code to demonstrate this. Create an object and put in the master code in one script and the slave in a second named "SS". Every other time you touch it, it will toggle the SS script which will tell you its state which should always be "secondState" after it starts. Get it to SS inactive then take it into inventory and rerez it. Now next time you touch it it will be back in the default state. Doing the same thing with it active correctly keeps it in secondState.
/////////// MASTER CODE ///////////
integer sState = FALSE;
default {
state_entry() {
llSetScriptState("SS", sState);
}
touch(integer num) {
sState = !sState;
llOwnerSay("Setting SS active to " + (string)sState);
llSetScriptState("SS", sState);
if (sState) {
llMessageLinked(LINK_THIS, 0, "", NULL_KEY);
}
}
}
/////////////// SLAVE CODE ///////////////////
// Put in script named SS
default {
state_entry() {
llOwnerSay(llGetScriptName() + " Entry Default State");
state secondState;
}
link_message(integer sender, integer num, string str, key id) {
llOwnerSay(llGetScriptName() + " In Default State");
}
}
state secondState {
state_entry() {
llOwnerSay(llGetScriptName() + " Entry secondState");
}
link_message(integer sender, integer num, string str, key id) {
llOwnerSay(llGetScriptName() + " In secondState");
}
}
]
|
|
/////////// MASTER CODE /////////// integer sState = FALSE; default { state_entry() { llSetScriptState("SS", sState); } touch(integer num) { sState = !sState; llOwnerSay("Setting SS active to " + (string)sState); llSetScriptState("SS", sState); if (sState) { llMessageLinked(LINK_THIS, 0, "", NULL_KEY); } } } /////////////// SLAVE CODE /////////////////// // Put in script named SS integer count = 0; default { state_entry() { llOwnerSay(llGetScriptName() + " Entry Default State count: " + (string)count); state secondState; } link_message(integer sender, integer num, string str, key id) { llOwnerSay(llGetScriptName() + " In Default State count: " + (string)count); } } state secondState { state_entry() { llOwnerSay(llGetScriptName() + " Entry secondState count: " + (string)count); } link_message(integer sender, integer num, string str, key id) { count += 1; llOwnerSay(llGetScriptName() + " In secondState count: " + (string)count); } }