Difference between revisions of "OnObjectEquipped - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>IsharaMeradin
(→‎Examples: modify source lang tag value to remove "error" boxes)
m (Minor note that this event fires for more than just weapons and armor.)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
'''Member of:''' [[Actor Script]]
'''Member of:''' [[Actor Script]]


Event called when the actor equips an object.
Event called when the actor equips an object. Note that this includes consumable objects such as potions.


== Syntax ==
== Syntax ==
Line 16: Line 16:


== Examples ==
== Examples ==
<source lang="text">
<source lang="papyrus">
Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
   if akBaseObject as Weapon
   if akBaseObject as Weapon
Line 26: Line 26:
== Notes ==
== Notes ==
*An [[OnObjectUnequipped - Actor|OnObjectUnequipped()]] event will always get sent before [[OnObjectEquipped - Actor|OnObjectEquipped()]] when equipping an item to an occupied equipment slot.
*An [[OnObjectUnequipped - Actor|OnObjectUnequipped()]] event will always get sent before [[OnObjectEquipped - Actor|OnObjectEquipped()]] when equipping an item to an occupied equipment slot.
**The OnObjectEquipped() event does not wait for the OnObjectUnequipped() event to complete before starting.  Adding the Utility.Wait(n) function at the beginning of the OnObjectEquipped() event script can help ensure it waits for the first event to finish.


== See Also ==
== See Also ==

Latest revision as of 23:08, 1 December 2021

Member of: Actor Script

Event called when the actor equips an object. Note that this includes consumable objects such as potions.

Syntax[edit | edit source]

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

Parameters[edit | edit source]

  • akBaseObject: The base object the actor just equipped.
  • akReference: The reference that the actor just equipped - if the reference is persistent. Otherwise, None.

Examples[edit | edit source]

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
  if akBaseObject as Weapon
    Debug.Trace("This actor just equipped a weapon!")
  endIf
endEvent

Notes[edit | edit source]

  • An OnObjectUnequipped() event will always get sent before OnObjectEquipped() when equipping an item to an occupied equipment slot.
    • The OnObjectEquipped() event does not wait for the OnObjectUnequipped() event to complete before starting. Adding the Utility.Wait(n) function at the beginning of the OnObjectEquipped() event script can help ensure it waits for the first event to finish.

See Also[edit | edit source]