Broadcasting Posted November 23, 2022 Share Posted November 23, 2022 Anybody know where I can find a script that can activate/deactivate another script inside a rezed prim by using a hud button? im not really to educated on scripting to go about it, so if anybody knows where one is on marketplace or inworld let me know I seriously cant find one by searching or maybe im just using wrong words. Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted November 23, 2022 Share Posted November 23, 2022 (edited) Asking for finding existing products should be done in the Wanted forum. Although what you are seeking can be accomplished with the command llSetScriptState. One of the caveats is that the function can only target scripts in the same prim. So you need to set up a communication framework between the HUD and the script that uses llSetScriptState - which in turn will set the state of the target script. Here is an extremely quick example using 3 scripts: // Object A // cotains this script. Touching it will broadcast the START or STOP message integer toggle = FALSE; default { touch_start(integer total_number) { if(toggle = !toggle) { llSay(1, "STOP"); } else { llSay(1, "START"); } } } . // Object B // cotains this script and the "target script". // Receives the start/stop message and sets the state of the "target script" accordingly default { state_entry() { llListen(1, "","",""); } listen(integer channel, string name, key id, string msg) { llOwnerSay("received signal: "+msg); if(msg=="STOP") { llSetScriptState("target script",FALSE); } else if(msg=="START") { llSetScriptState("target script",TRUE); } } } . // Object B // The target script that will be set active/inactive by the other scripts. // For this example it's just the default hello world script. // But make sure to rename this script to "target script" so the other one can find it. default { state_entry() { llSay(0, "Hello, Avatar!"); } touch_start(integer total_number) { llSay(0, "Touched."); } } Drop the first script into object A, and the other two into object B. Make sure to rename the 3rd script to be "target script" since that's what the 2nd script is looking for. When you click Object B, it should say "Touched." as per usual. Clicking on object A will send the START or STOP signal which will be heard by the 2nd script in object B. When the STOP signal is sent, you will notice that clicking on object B no longer does anything - because that script has been suspended. Clicking object A again to send the START signal will reactivate it. Edited November 23, 2022 by Fenix Eldritch 1 Link to comment Share on other sites More sharing options...
Broadcasting Posted December 13, 2022 Author Share Posted December 13, 2022 On 11/23/2022 at 8:08 AM, Fenix Eldritch said: Asking for finding existing products should be done in the Wanted forum. Although what you are seeking can be accomplished with the command llSetScriptState. One of the caveats is that the function can only target scripts in the same prim. So you need to set up a communication framework between the HUD and the script that uses llSetScriptState - which in turn will set the state of the target script. Here is an extremely quick example using 3 scripts: // Object A // cotains this script. Touching it will broadcast the START or STOP message integer toggle = FALSE; default { touch_start(integer total_number) { if(toggle = !toggle) { llSay(1, "STOP"); } else { llSay(1, "START"); } } } . // Object B // cotains this script and the "target script". // Receives the start/stop message and sets the state of the "target script" accordingly default { state_entry() { llListen(1, "","",""); } listen(integer channel, string name, key id, string msg) { llOwnerSay("received signal: "+msg); if(msg=="STOP") { llSetScriptState("target script",FALSE); } else if(msg=="START") { llSetScriptState("target script",TRUE); } } } . // Object B // The target script that will be set active/inactive by the other scripts. // For this example it's just the default hello world script. // But make sure to rename this script to "target script" so the other one can find it. default { state_entry() { llSay(0, "Hello, Avatar!"); } touch_start(integer total_number) { llSay(0, "Touched."); } } Drop the first script into object A, and the other two into object B. Make sure to rename the 3rd script to be "target script" since that's what the 2nd script is looking for. When you click Object B, it should say "Touched." as per usual. Clicking on object A will send the START or STOP signal which will be heard by the 2nd script in object B. When the STOP signal is sent, you will notice that clicking on object B no longer does anything - because that script has been suspended. Clicking object A again to send the START signal will reactivate it. Oh sorry went on vacation and forgot to check back here lmao but script works perfectly thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now