OnOpen

The script attached to this event fires when an object has been opened.


Trigger

Door or placeable object was opened.


Function(s)

GetLastOpenedBy() returns the object that opened OBJECT_SELF.


Remarks

Only placeable objects with inventories (has the "Has Inventory" check box checked) can be opened. If a placable object is opened, it doesn't mean anything has been, will be, or might be taken from it. Also, there is no real way to set a state of a placable - unlike a door, which can be closed again. Placables are only closed if the creature opening them is stopped (ClearAllActions()), killed, removed, or moves away and so forth.


Example

// In an doors On Open event, we close ourselves after 15 seconds
// because of drafts.

void CloseMe()
{
    // Can't close ourselves twice
    if(GetIsOpen(OBJECT_SELF))
    {
        ActionCloseDoor(OBJECT_SELF);
        SpeakString("*A draft closes this door*);
    }
}

void main()
{
    // 15 second delay in the On Open event.
    DelayCommand(15.0, CloseMe());
}

See Also

Objects with Events | Door | Placeable Object
functions: GetLastOpenedBy