User:Toady Nakamura/Owner Only

From Second Life Wiki
< User:Toady Nakamura
Revision as of 15:35, 5 March 2021 by Toady Nakamura (talk | contribs) (new page for owner only conditionals... will add more)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

If you want your object to only react to the owner, you need to get and use the owner's UUID key.

Filter the key of the toucher against the owner's key by using the conditional format (if *what I got* == *the limiting factor*).

This example of how to do it shows that if toucher is owner, make box green, else make box red!

key owner;

default
{
    state_entry()
    {
        owner = llGetOwner();
    }
    
    touch_start(integer num_detected)
    {
        if(llDetectedKey(0) == owner)
        {
           llSetColor(<0,1,0>, ALL_SIDES);
        }
        else
        {
           llSetColor(<1,0,0>, ALL_SIDES);
        }
    }

    changed(integer change)
    {    
        if (change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
}
  • changed event

You need this event so if the item changes to new owner, it resets and gets the new owner's UUIDkey... otherwise it stays fixated on the first one it ever knew as its owner





Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura