Background for Fallout 4
Member of the ObjectReference script
voidfunctionRemoveComponents(ComponentakComponent, intaiCount, boolabSilent=false)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. When one is found, the item is scrapped, the components removed, and the remaining components returned to the container.
  • 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 scrapped.
  • To remove items without scrapping, use ObjectReference.RemoveItem(...) or ObjectReference.RemoveItemByComponent(...)

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, and no change will be given.
  • 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, and one copper will be returned.
  • If the container has two objects that provide one copper and one glass, and you call this function with copper and glass, and a count of two, then both items will be removed, and two glass will be returned.

Parameters

ComponentakComponent

CK Wiki Description

The component to remove.

intaiCount

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


Examples

; Remove 5 leather, scrapping items and returning remainder to Chest
Chest.RemoveComponents(c_Leather, 5)
; Remove 5 leather, scrapping items and returning remainder to the player, but with no messages on screen
Player.RemoveComponents(c_Leather, 5, true)

Auto-Generated Example

Component myComponent__akComponent
int myInt__aiCount
bool myBool__abSilent

myObjectReference__toCallFunctionOn.RemoveComponents(myComponent__akComponent, myInt__aiCount, myBool__abSilent)

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.