Background for Fallout 4
Member of the ObjectReference script
eventOnItemAdded(FormakBaseItem, intaiItemCount, ObjectReferenceakItemReference, ObjectReferenceakSourceContainer)

Description

Wiki Description

Event received when an item is inserted into this object's container. Only arrives if it matches an inventory filter in place on the script receiving the event.

Documentation Comment

Event received when an item is added to this object's inventory. If the item is a persistant reference, akItemReference will
point at it - otherwise the parameter will be None


Caveats

CK Wiki - Notes

  • Once an object has been added to a container it usually no longer exists. You can then only call inventory-safe functions on it.
  • You must use AddInventoryEventFilter to receive this event, letting it know what items you care about.

Parameters

  1. FormakBaseItem

    CK Wiki Description

    The base object for the item that was added to this container.

  2. intaiItemCount

    CK Wiki Description

    The number of items added to this container.

  3. ObjectReferenceakItemReference

    CK Wiki Description

    The specific reference added to the container, if any. Will be None if a non-persistant object is added.

  4. ObjectReferenceakSourceContainer

    CK Wiki Description

    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 game me " + aiItemCount + "x " + akBaseItem)
  else
    Debug.Trace("I got " + aiItemCount + "x " + akBaseItem + " from another container")
  endIf
endEvent

Auto-Generated Example

Scriptname MyCoolScript extends ObjectReference

event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    Debug.trace("Event received - OnItemAdded: akBaseItem = " + akBaseItem + " aiItemCount = " + aiItemCount + " akItemReference = " + akItemReference + " akSourceContainer = " + akSourceContainer)
endEvent

Related Pages


Additional References

View this event’s page on the Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.