Reset from Child Plugin - Second Life Wiki

Reset from Child Plugin

From Second Life Wiki

Second Life Wiki > Reset from Child Plugin
Jump to: navigation, search

Thanks to Gillian Uxlay for writing this script and allowing it in the wiki. This script goes in the main prim with all the MLP scripts. It could also be used in any other object that you would like to reset scripts in without having to 'edit linked-> reset all scripts in selection'. It can probably be modded to just reset specific scripts as well. It is activated by the second script in any child prim that you want to use for a 'reset prim'.

//Written and donated by Gillian Uxlay
// just call this script using llMessageLinked( LINK_ROOT, RESET_ALL_SCRIPTS, "", "" );
 
integer RESET_ALL_SCRIPTS = -5102104;
 
resetAllScripts(){
    integer l = llGetInventoryNumber( INVENTORY_SCRIPT );
    integer i;
    for( i = 0; i < l; i++ ){
        string name = llGetInventoryName( INVENTORY_SCRIPT, i );
        if( name != llGetScriptName() ){
            llResetOtherScript( name );
        }
    }
    llResetScript();
}
 
default
{
    state_entry()
    {
    }
    link_message( integer sender_num, integer num, string message, key id ){
        if( num == RESET_ALL_SCRIPTS ){
            resetAllScripts();
        }
    }
}

This is a basic dialog script by Alicia Stella that I modded to go in any child prim. It will give a menu to reset or not reset all the scripts in the main prim. It may work if MLP is not in the main prim, but that has yet to be tested. It will take up to 12 buttons if you wish to use them to save on ~menu memory. It can be accessed by all, unless the owner sets it to 'not running' or someone with more script skill than I wants to mod it to group or owner only access.

list MENU_MAIN = ["Reset", "No Reset"]; //up to 12 in list
 
integer menu_handler;
integer menu_channel;
integer RESET_ALL_SCRIPTS = -5102104;
menu(key user,string title,list buttons)
{
    llListenRemove(menu_handler); //BugFix 5/2008
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(30.0); //how long to wait for user to press a button before giving up and closing listen
}
 
default
{
    state_entry()
    {
        //nada
    }
 
    touch_start(integer total_number)
    {
        menu(llDetectedKey(0), "\nRemote Reset Menu", MENU_MAIN);
    }
 
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) 
        {
            llListenRemove(menu_handler); //close listen
            llSetTimerEvent(0); //stop timeout timer
            if (message == "Reset")
            {
                llSay(0, "Reseting main scripts...");
                llMessageLinked( LINK_ROOT, RESET_ALL_SCRIPTS, "", "" );
            }
            else if (message == "No Reset")
            {
                llSay(0, "No Resets Done.");
            }
            //else if (message == "Button3")
            //{
                //do something
            //}
        }
    }
 
    timer() //VERY IMPORTANT menu timeout
    {
        llListenRemove(menu_handler); //close listen
        llSetTimerEvent(0); //stop timeout timer
    }
}