OnUsed

From NWN Lexicon
Jump to navigationJump to search

The script attached to this event fires when a placeable object is used. This can be used to open a door or set off a trap when a lever is pulled or a brazier is extinguished.


Trigger

When a placeable object is used (clicked on, moved up to and interacted with).


Function(s)


Remarks

Note that the OnClick event fires instantly, while this event waits until the creature is in a usable range (seems to be creatures PERSPACE + 0.5M to the usable spot of the object). This is the better one to use for levers, while OnClicked works for selecting things at a distance (eg; something in the water).

You can use PlayAnimation to make a placeable object move (eg a lever being thrown on or off) with the ANIMATION_PLACEABLE_OPEN, ANIMATION_PLACEABLE_CLOSE, ANIMATION_PLACEABLE_ACTIVATE and ANIMATION_PLACEABLE_DEACTIVATE options.

You'd use SetPlaceableIllumination can turn on/off a light source, for example, a brazier or fire.

For an easy way to have a conversation start use the script nw_g0_convplac which starts the placeables assigned conversation.


Making It Trigger

If you're assigning a creature to use an item, use DoPlaceableObjectAction or ActionInteractObject, which fire this event as if a PC had clicked on it.


See Also

functions: 

GetLastUsedBy()