RemoveComponents - ObjectReference

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ObjectReference Script

Removes the a certain count of a specified component from the container's inventory, scrapping objects as necessary, and returning the change to the container.

Syntax[edit | edit source]

Function RemoveComponents(Component akComponent, int aiCount, bool abSilent = false) native

Parameters[edit | edit source]

  • akComponent: The component to remove.
  • aiCount: How many components to remove. (Not items)
    • Default: 1
  • abSilent: If true, no message will be printed to the screen
    • Default: false

Return Value[edit | edit source]

None.

Examples[edit | edit source]

; 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)

Notes[edit | edit source]

  • 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 RemoveItem or 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.

See Also[edit | edit source]