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

[DEV SERVER] Loading description...


Caveats

CK Wiki - Notes

  • The function searches the object's inventory in the order it is stored in memory looking for objects with the specified component or one of the components in the form list. When one is found, that item is removed from inventory and the number to be removed is deducted by the component count of the removed item. The process continues until the number to be removed reaches zero.
  • This function is dependent on the order in which the items are stored and therefore gives the caller no control over which or how many items are actually removed.
  • To remove [n] items with the given component, rather than [n] components, use ObjectReference.RemoveItem(...) instead.
  • Items are removed, they are not scrapped, and the "change" is not returned to the container. If you want scrapping behavior, use ObjectReference.RemoveComponents(...) instead.

Examples:

  • If the container has two objects that each have two copper, and you call this function with copper, and a count of two, then one item will be removed.
  • If the container has two objects that each have two copper, and you call this function with copper, and a count of three, then both items will be removed.
  • If the container has two objects that provide one copper and one glass, and you call this function with a form list containing copper and glass, with a count of two, then one item will be removed.

Parameters

FormakComponentToRemove

CK Wiki Description

The component or form list of components the items to be removed must contain.

intaiCount=1

CK Wiki Description

How many components to remove. (Not items)

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

; Remove 5 (or more) leather
Chest.RemoveItemByComponent(c_Leather, 5)

Auto-Generated Example

Form myForm__akComponentToRemove
int myInt__aiCount
bool myBool__abSilent
ObjectReference myObjectReference__akOtherContainer

myObjectReference__toCallFunctionOn.RemoveItemByComponent(myForm__akComponentToRemove, 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.