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 placeable object is opened, it doesn't mean anything has been, will be, or might be taken from it. You can detect most changes to a placeables inventory with the OnDisturbed event. Also, there is no real way to set a state of a placeable - unlike a door, which can be closed again. Placeables are only closed if the creature opening them is stopped (ClearAllActions()), killed, removed, or moves away and so forth.
Placeables never seem to reorder their inventory pages automatically - ie sort by item type - unlike stores. When a placeable is first generated into the world the inventory seems to merge any stackable items appropriately but usually leaves the order the same as things being added, fitting stuff in best it can.
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
| functions: |