A reference to an item and count owned by some external entity.
In most instances this is a simple reference as in: it points at a specific slot in an inventory and not the item in the slot.
In the instance this references an item on a LuaTransportLine the reference is only guaranteed to stay valid (and refer to the same item) as long as nothing changes the transport line.
LuaItemCommonbooleanunknownfalseIs this valid for reading? Differs from the usual valid in that valid will be true even if the item stack is blank but the entity that holds it is still valid.
LuaItemPrototypeunknownfalsePrototype of the item held in this stack.
stringunknownfalsePrototype name of the item held in this stack.
stringunknownfalseType of the item prototype.
uint32uint32falseNumber of items in this stack.
floatfloatfalseHow much health the item has, as a number in range [0, 1].
LuaQualityPrototypeunknownfalseThe quality of this item.
MapTickMapTickfalseThe tick this item spoils, or 0 if it does not spoil. When writing, setting to anything < the current game tick will spoil the item instantly.
doubledoublefalseThe percent spoiled this item is if it spoils. 0 in the case of the item not spoiling.
LuaItemunknowntrueIf the item has additional data, returns LuaItem pointing at the extra data, otherwise returns nil.
booleanunknownfalseIf this is a module
booleanunknownfalseIs this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
stringunknownfalseThe class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
LuaItemStack.add_ammo(amount: float)
itemStack.add_ammo(amount)
takes_table: falsetable_optional: falseAdd ammo to this ammo item.
amount: float — Amount of ammo to add.LuaItemStack.drain_ammo(amount: float)
itemStack.drain_ammo(amount)
takes_table: falsetable_optional: falseRemove ammo from this ammo item.
amount: float — Amount of ammo to remove.LuaItemStack.add_durability(amount: double)
itemStack.add_durability(amount)
takes_table: falsetable_optional: falseAdd durability to this tool item.
amount: double — Amount of durability to add.LuaItemStack.drain_durability(amount: double)
itemStack.drain_durability(amount)
takes_table: falsetable_optional: falseRemove durability from this tool item.
amount: double — Amount of durability to remove.LuaItemStack.use_capsule(entity: LuaEntity, target_position: MapPosition) -> Array<LuaEntity>
itemStack.use_capsule(entity, target_position)
takes_table: falsetable_optional: falseUse the capsule item with the entity as the source, targeting the given position.
entity: LuaEntity — The entity to use the capsule item with.target_position: MapPosition — The position to use the capsule item with.Array<LuaEntity> — Array of the entities that were created by the capsule action.LuaItemStack.can_set_stack(stack?: ItemStackIdentification) -> boolean
itemStack.can_set_stack()
takes_table: falsetable_optional: falseWould a call to LuaItemStack::set_stack succeed?
stack?: ItemStackIdentification — Stack that would be set, possibly nil.booleanLuaItemStack.set_stack(stack?: ItemStackIdentification) -> boolean
itemStack.set_stack()
takes_table: falsetable_optional: falseSet this item stack to another item stack.
stack?: ItemStackIdentification — Item stack to set it to. Omitting this parameter or passing nil will clear this item stack, as if LuaItemStack::clear was called.boolean — Whether the stack was set successfully. Returns false if this stack was not valid for write.LuaItemStack.transfer_stack(stack: ItemStackIdentification, amount?: uint32) -> boolean
itemStack.transfer_stack(stack, amount)
takes_table: falsetable_optional: falseTransfers the given item stack into this item stack.
stack: ItemStackIdentificationamount?: uint32boolean — true if the full stack (or requested amount) was transferred.LuaItemStack.export_stack() -> string
itemStack.export_stack()
takes_table: falsetable_optional: falseExport a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string.
string — The exported stringLuaItemStack.import_stack(data: string) -> int32
itemStack.import_stack(data)
takes_table: falsetable_optional: falseImport a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string.
data: string — The string to importint32 — 0 if the import succeeded with no errors. -1 if the import succeeded with errors. 1 if the import failed.LuaItemStack.swap_stack(stack: LuaItemStack) -> boolean
itemStack.swap_stack(stack)
takes_table: falsetable_optional: falseSwaps this item stack with the given item stack if allowed.
stack: LuaItemStackboolean — Whether the 2 stacks were swapped successfully.LuaItemStack.clear()
itemStack.clear()
takes_table: falsetable_optional: falseClear this item stack.
LuaItemStack.create_grid() -> LuaEquipmentGrid
itemStack.create_grid()
takes_table: falsetable_optional: falseCreates the equipment grid for this item if it doesn't exist and this is an item-with-entity-data that supports equipment grids.
LuaEquipmentGridLuaItemStack.spoil()
itemStack.spoil()
takes_table: falsetable_optional: falseSpoils this item if the item can spoil.