Difference between revisions of "OnItemAdded - ObjectReference"
Jump to navigation
Jump to search
imported>Plplecuyer (→Notes) |
imported>Goggle (→Notes: Items caught that are the same type of an item equipped, will return the equipped item instead.) |
||
Line 33: | Line 33: | ||
*Once an object has been added to a container it usually no longer exists. You can then only call inventory-safe functions on it. | *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 - ObjectReference|AddInventoryEventFilter]] to receive this event, letting it know what items you care about. | *You must use [[AddInventoryEventFilter - ObjectReference|AddInventoryEventFilter]] to receive this event, letting it know what items you care about. | ||
*This event will return the item of the same type that is equipped, instead of the item that has been caught by the event, if you need to remove that for any reason. In other words, it appears this event cannot differentiate between an equipped item from an unequipped item of the same type. | |||
== See Also == | == See Also == |
Revision as of 08:59, 14 August 2016
Member of: ObjectReference Script
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.
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 game 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 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.
- This event will return the item of the same type that is equipped, instead of the item that has been caught by the event, if you need to remove that for any reason. In other words, it appears this event cannot differentiate between an equipped item from an unequipped item of the same type.