Background for Fallout 4
Member of the ObjectReference script
voidfunctionRemoveItem(FormakItemToRemove, intaiCount=1, boolabSilent=false, ObjectReferenceakOtherContainer=NONE)Native

Description

Wiki Description

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

Documentation Comment

Removes the specified item from this object reference's inventory


Caveats

CK Wiki - Notes

  • 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 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).
  • if using a keyword for akitem the keyword must be defined on the base form. Keywords added at runtime are ignored by this function.

Parameters

FormakItemToRemove

CK Wiki Description

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.
    • Note:The keyword must be defined on the base form.
  • Component - removes no more than aiCount of items containing at least 1 of the component

intaiCount=1

CK Wiki Description

How many references to remove.

  • Note: Values less than 0 will remove all the items of this type.

boolabSilent=false

CK Wiki Description

If true, no message will be printed to the screen

ObjectReferenceakOtherContainer=NONE

CK Wiki Description

If not None, the removed item(s) will be moved into this ref's inventory


Examples

; Take away an apple
Chest.RemoveItem(Apple)
; Remove 50 gold from the player
Game.GetPlayer().RemoveItem(GoldBase, 50)

Auto-Generated Example

Form myForm__akItemToRemove
int myInt__aiCount
bool myBool__abSilent
ObjectReference myObjectReference__akOtherContainer

myObjectReference__toCallFunctionOn.RemoveItem(myForm__akItemToRemove, myInt__aiCount, myBool__abSilent, myObjectReference__akOtherContainer)

Related Pages


Additional References

View this function’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.