Difference between revisions of "RemoveItem - ObjectReference"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Goggle
m (The issue lies with the OnItemAdded Event and not RemoveItem.)
imported>Kalevala
 
(One intermediate revision by one other user not shown)
Line 42: Line 42:


==Notes==
==Notes==
*The function accepts a form object, however you can't make a property to a form object, you need to create a property to another type of object that extends form. Most often a MiscObject, or Weapon, etc.
*Keywords and components in FormLists are supported as well, including mixed base objects, keywords, and components.
*Keywords and components in FormLists are supported as well, including mixed base objects, keywords, and components.
*Removing items by component does not scrap the items like extracting components via the workshop does, it simply removes the item itself (and which item is removed if multiple items have the specified component is non-deterministic). If you want to scrap, use [[RemoveComponents - ObjectReference|RemoveComponents]]
*Removing items by component does not scrap the items like extracting components via the workshop does, it simply removes the item itself (and which item is removed if multiple items have the specified component is non-deterministic). If you want to scrap, use [[RemoveComponents - ObjectReference|RemoveComponents]]
*The function seems to have a preference for equipped items. Or if not equipped items then the first instance of the item that's in inventory (which is the same thing, since when you equip something, it's the first instance of the object in the inventory).


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

Latest revision as of 16:12, 23 January 2018

Member of: ObjectReference Script

Removes X of the specified item from this reference's inventory, possibly silently.

Syntax[edit | edit source]

Function RemoveItem(Form akItemToRemove, int aiCount = 1, bool abSilent = false, ObjectReference akOtherContainer = None) native

Parameters[edit | edit source]

  • akItemToRemove: The function will accept several variants:
    • ObjectReference - if a reference is passed, the reference is deleted once it's removed.
      • Note: This can accept non-persistent references in containers.
    • Base object - removes no more than aiCount of that item.
    • FormList of base objects, keywords, or components - removes no more than aiCount of items, starting with the first item in the form list and working down the form list.
    • Keyword - removes no more than aiCount of items matching that keyword from the container.
    • Component - removes no more than aiCount of items containing at least 1 of the component
  • aiCount: How many references to remove.
    • Default: 1
    • Note: Values less than 0 will remove all the items of this type.
  • abSilent: If true, no message will be printed to the screen
    • Default: false
  • akOtherContainer: If not None, the removed item(s) will be moved into this ref's inventory
    • Default: None

Return Value[edit | edit source]

None.

Examples[edit | edit source]

; Take away an apple
Chest.RemoveItem(Apple)


; Remove 50 gold from the player
Game.GetPlayer().RemoveItem(GoldBase, 50)

Notes[edit | edit source]

  • Keywords and components in FormLists are supported as well, including mixed base objects, keywords, and components.
  • Removing items by component does not scrap the items like extracting components via the workshop does, it simply removes the item itself (and which item is removed if multiple items have the specified component is non-deterministic). If you want to scrap, use RemoveComponents
  • The function seems to have a preference for equipped items. Or if not equipped items then the first instance of the item that's in inventory (which is the same thing, since when you equip something, it's the first instance of the object in the inventory).

See Also[edit | edit source]