Don't click here unless you want to be banned.

LSL Wiki : LibraryRuntimeEnvironment

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl423.us.archive.org

Runtime Environment


A script to detect changes in an objects runtime environment.

These conditions are detected:

player login (if the object is attached)
script reset (state_entry) on ground
script reset (state_entry) while worn
worn from inventory
worn from ground
dropped while attached
dropped from inventory

This is a toy script that could be usefull for specific applications if tweaked a bit. I got frustrated today trying to make heads or tails of what to do when different combinations of the on_rez(), state_entry(), attach() callbacks were called. I wanted a higher level abstraction of what was going on with the object so I could decide how to react.

I also didn't want my main script to be all uglified trying to figure this stuff out.

This script does the trick. By capturing the state of various indicators we can derive some more meaningfull ideas about what's going on with the script. And with a bit of tweaking, this script could let other scripts know when things changed so they could react appropriately without needing to worry about the low level stuff.

The name could be better, but I couldn't think of anything decent that quite captured this concept. If you have a better name be sure and let me know ;-)

Feel free to use or modify this script in your own objects for any purpose.

// runtime environment // ready jack // 13 Nov 2005 // v1.0

float delay = 3.0;
integer reset;
integer rezzed;
integer worn;
integer removed;

out(string message) {
    llWhisper(0, message);
    //llMessageLinked(LINK_SET, 0, "environment " + message, NULL_KEY);
}

default
{
    state_entry()
    {
        ++reset;
        if (llGetAttached()) ++worn;
        llSetTimerEvent(delay);
    }
    
    on_rez(integer param) 
    {
        ++rezzed;
        llSetTimerEvent(delay);
    }
    
    attach(key who)
    {
        if (who != NULL_KEY) {
            ++worn;
        } else {
            ++removed;
        }
        llSetTimerEvent(delay);
    }
    
    timer()
    {
        llSetTimerEvent(0);
        
        if (reset && !worn)
                out("reset on ground");
        else if (reset && worn)
                out("reset while worn"); 
        else if (worn && rezzed && removed) 
                out("worn from inventory");
        else if (worn && rezzed && !removed) 
                out("login");
        else if (worn && !rezzed) 
                out("worn from ground");
        else if (!worn && !rezzed && removed) 
                out("dropped while attached");
        else if (!worn && rezzed) 
                out("dropped from inventory");
        else out("unexpected runtime environment");
        
        worn = removed = rezzed = reset = 0;
    }
}


ScriptLibrary
Comments [Hide comments/form]
Should be called Extended Events Environment :P
-- KairaOverdrive (2005-11-22 10:38:24)
probably
-- BlindWanderer (2005-11-23 15:42:36)
Attach a comment to this page: