Various changes to the object/prim trigger this event.

Syntax

changed( integer change )

Event ID: 30.

Parameters

integer change (bit_field)
bit field of CHANGED_* flags

Multiple changes can be represented in a single event, so use bitwise arithmetic.

Constants

FlagDescriptionScope
CHANGED_INVENTORY0x001Prim inventory has changed[1].prim
CHANGED_COLOR0x002Prim color or alpha parameters have changed.prim
CHANGED_SHAPE0x004Prim shape has changed.prim
CHANGED_SCALE0x008Prim scale has changed.prim
CHANGED_TEXTURE0x010Prim texture parameters have changed.prim
CHANGED_LINK0x020The number of prims making up the object or avatars seated on the object have changed.object
CHANGED_ALLOWED_DROP0x040A user other than the owner (or the owner if the object is no-mod) has added inventory to the prim.prim
CHANGED_OWNER0x080The object has changed owners.object
CHANGED_REGION0x100The object has changed region.object
CHANGED_TELEPORT0x200The avatar to whom this object is attached has teleported.object
CHANGED_REGION_START0x400The region this object is in has just come online.region
CHANGED_MEDIA0x800Prim Media has changed.prim
CHANGED_RENDER_MATERIAL0x1000Render Material has changed.prim

Caveats

Examples

default
{
    changed(integer change)
    {
        // note that it's & and not &&... it's bitwise!
        if (change & CHANGED_INVENTORY)         
        {
            llOwnerSay("The inventory has changed.");
        }
        if (change & CHANGED_COLOR) 
        {
            llOwnerSay("The color or alpha changed.");
        }
        if (change & CHANGED_SHAPE) 
        {
            llOwnerSay("The prims shape has changed.");
        }
        if (change & CHANGED_SCALE) 
        {
            llOwnerSay("The prims size has changed.");
        }
        if (change & CHANGED_TEXTURE) 
        {
            llOwnerSay("The prims texture or texture attributes have changed.");
        }
        if (change & CHANGED_LINK) 
        {
            llOwnerSay("The number of links have changed.");
        }
        if (change & CHANGED_ALLOWED_DROP) 
        {
            llOwnerSay("The inventory has changed as a result of a user without mod permissions "+
                       "dropping an item on the prim and it being allowed by the script.");
        }
        if (change & CHANGED_OWNER) 
        {
            llOwnerSay("The owner of the object has changed.");
        }
        if (change & CHANGED_REGION) 
        {
            llOwnerSay("The region the object is in has changed.");
        }
        if (change & CHANGED_TELEPORT) 
        {
            llOwnerSay("The object has been teleported while attached.");
        }
        if (change & CHANGED_REGION_START) 
        {
            llOwnerSay("The regions has just restarted.");
        }
    }
}

For the same action to be called for multiple changes we can use the following syntax:

default
{
    changed(integer change)
    {
        if(change & (CHANGED_OWNER | CHANGED_INVENTORY)) // Either of the changes will return true.
            llResetScript();
    }
}

Notes

default
{
    changed(integer change)
    {
        if(change & CHANGED_LINK)
        {
            integer links = 0;
            if(llGetObjectPrimCount(llGetKey()) < (links = llGetNumberOfPrims()))
            {
                llUnSit(llGetLinkKey(links));
                state whatever;
            }
            else
            llOwnerSay("Some kind of linking or unlinking has changed me but, I am not being sat on.");
            // This will be chatted after returning to the default state.
        }
    }
}
state whatever
{
    state_entry()
    {
        llSetTimerEvent(10.0);
    }
    timer()
    {
        state default;
    }
}

Deep notes

Issues

Footnotes

  1. CHANGED_INVENTORY won't be triggered if the inventory change was caused by a script function or a user taking advantage of llAllowInventoryDrop
  2. Remember, as of 2024, this may be an archived vote.