Difference between revisions of "OnItemAdded - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Layam
m (Grammar)
imported>Layam
(Moving note on force-equipping items to EquipItem page.)
Line 33: Line 33:
*Once an object has been added to a container it is no longer valid to call member functions on it. Member functions on akItemReference (which is often None) will most likely fail to run with an error.
*Once an object has been added to a container it is no longer valid to call member functions on it. Member functions on akItemReference (which is often None) will most likely fail to run with an error.
*If you only care about certain kinds of objects, you should also use [[AddInventoryEventFilter - ObjectReference|AddInventoryEventFilter]] to filter out any events for things you aren't interested in.
*If you only care about certain kinds of objects, you should also use [[AddInventoryEventFilter - ObjectReference|AddInventoryEventFilter]] to filter out any events for things you aren't interested in.
*Although you can use this event to force actors to equip items in [[OpenInventory - Actor|OpenInventory]] or pick-pocketing dialogues, those items will not be visible on the actor until the dialogue is ended. Calling the SKSE function [[QueueNiNodeUpdate - Actor|QueueNiNodeUpdate]] straight after calling EquipItem can force the actor to draw the new equipment immediately.


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

Revision as of 04:34, 28 March 2013

Member of: ObjectReference Script

Event received when an item is inserted into this object's container.

Syntax

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

Parameters

  • akBaseItem: The base object for the item that was added to this container.
  • aiItemCount: The number of items added to this container.
  • akItemReference: The specific reference added to the container, if any. Will be None if a non-persistant object is added.
  • akSourceContainer: The container that the object(s) came from. If None, then the object came from the world.

Examples

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  if !akSourceContainer
    Debug.Trace("I picked up " + aiItemCount + "x " + akBaseItem + " from the world")
  elseif akSourceContainer == Game.GetPlayer()
    Debug.Trace("The player gave me " + aiItemCount + "x " + akBaseItem)
  else
    Debug.Trace("I got " + aiItemCount + "x " + akBaseItem + " from another container")
  endIf
endEvent

Notes

  • Once an object has been added to a container it is no longer valid to call member functions on it. Member functions on akItemReference (which is often None) will most likely fail to run with an error.
  • If you only care about certain kinds of objects, you should also use AddInventoryEventFilter to filter out any events for things you aren't interested in.

See Also