Stopping LSL scripts running in the wrong object

I’ve been dusting off a very old project in Second Life and giving it a fresh coat of pixels (details to follow) where I wanted to use llRemoteLoadScriptPin to load scripts into objects as I rez them. It would however cause odd things to happen if these scripts ran in the object doing the rezzing, so here’s how I stop them:

default 
{
    state_entry()
    {
        // Check whether we should be running...
        integer disable_marker = llGetInventoryType("DisableScripts");
        if(disable_marker != INVENTORY_NONE)
        {
            state disabled;
        }

        // ... the real code
    }
}

state disabled
{
    state_entry()
    {
        llSetScriptState(llGetScriptName(), FALSE);
        // Nothing else in this state so it shouldn't matter if the
        // script doesn't stop immediately
    }
}

So the script magically stops running if I put it in any object that contains a notecard with the name DisableScripts, which seems to work pretty well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s