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.
is_blueprint_setup() | → boolean |
Is this blueprint item setup? |
Is this blueprint item setup? |
||
get_blueprint_entities() | → array[BlueprintEntity]? |
The entities in this blueprint. |
The entities in this blueprint. |
||
set_blueprint_entities(entities) |
Set new entities to be a part of this blueprint. |
|
Set new entities to be a part of this blueprint. |
||
add_ammo(amount) |
Add ammo to this ammo item. |
|
Add ammo to this ammo item. |
||
drain_ammo(amount) |
Remove ammo from this ammo item. |
|
Remove ammo from this ammo item. |
||
add_durability(amount) |
Add durability to this tool item. |
|
Add durability to this tool item. |
||
drain_durability(amount) |
Remove durability from this tool item. |
|
Remove durability from this tool item. |
||
can_set_stack(stack?) | → boolean |
Would a call to LuaItemStack::set_stack succeed? |
Would a call to LuaItemStack::set_stack succeed? |
||
set_stack(stack?) | → boolean |
Set this item stack to another item stack. |
Set this item stack to another item stack. |
||
transfer_stack(stack) | → boolean |
Transfers the given item stack into this item stack. |
Transfers the given item stack into this item stack. |
||
export_stack() | → string |
Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string. |
Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string. |
||
import_stack(data) | → int |
Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string. |
Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string. |
||
swap_stack(stack) | → boolean |
Swaps this item stack with the given item stack if allowed. |
Swaps this item stack with the given item stack if allowed. |
||
clear() |
Clear this item stack. |
|
Clear this item stack. |
||
get_blueprint_tiles() | → array[Tile]? |
A list of the tiles in this blueprint. |
A list of the tiles in this blueprint. |
||
set_blueprint_tiles(tiles) |
Set specific tiles in this blueprint. |
|
Set specific tiles in this blueprint. |
||
get_inventory(inventory) | → LuaInventory? |
Access the inner inventory of an item. |
Access the inner inventory of an item. |
||
build_blueprint{surface=…, force=…, position=…, force_build?=…, direction?=…, skip_fog_of_war?=…, by_player?=…, raise_built?=…} | → array[LuaEntity] |
|
deconstruct_area{surface=…, force=…, area=…, skip_fog_of_war?=…, by_player?=…} |
Deconstruct the given area with this deconstruction item. |
|
Deconstruct the given area with this deconstruction item. |
||
cancel_deconstruct_area{surface=…, force=…, area=…, skip_fog_of_war?=…, by_player?=…} |
Cancel deconstruct the given area with this deconstruction item. |
|
Cancel deconstruct the given area with this deconstruction item. |
||
create_blueprint{surface=…, force=…, area=…, always_include_tiles?=…, include_entities?=…, include_modules?=…, include_station_names?=…, include_trains?=…, include_fuel?=…} | → dictionary[uint → LuaEntity] |
Sets up this blueprint using the found blueprintable entities/tiles on the surface. |
Sets up this blueprint using the found blueprintable entities/tiles on the surface. |
||
get_tag(tag_name) | → AnyBasic? |
Gets the tag with the given name or returns |
Gets the tag with the given name or returns |
||
set_tag(tag_name, tag) |
Sets the tag with the given name and value. |
|
Sets the tag with the given name and value. |
||
remove_tag(tag) | → boolean |
Removes a tag with the given name. |
Removes a tag with the given name. |
||
clear_blueprint() |
Clears this blueprint item. |
|
Clears this blueprint item. |
||
get_entity_filter(index) | → string? |
Gets the entity filter at the given index for this deconstruction item. |
Gets the entity filter at the given index for this deconstruction item. |
||
set_entity_filter(index, filter) | → boolean |
Sets the entity filter at the given index for this deconstruction item. |
Sets the entity filter at the given index for this deconstruction item. |
||
get_tile_filter(index) | → string? |
Gets the tile filter at the given index for this deconstruction item. |
Gets the tile filter at the given index for this deconstruction item. |
||
set_tile_filter(index, filter) | → boolean |
Sets the tile filter at the given index for this deconstruction item. |
Sets the tile filter at the given index for this deconstruction item. |
||
clear_deconstruction_item() |
Clears all settings/filters on this deconstruction item resetting it to default values. |
|
Clears all settings/filters on this deconstruction item resetting it to default values. |
||
clear_upgrade_item() |
Clears all settings/filters on this upgrade item resetting it to default values. |
|
Clears all settings/filters on this upgrade item resetting it to default values. |
||
get_mapper(index, type) | → UpgradeFilter |
Gets the filter at the given index for this upgrade item. |
Gets the filter at the given index for this upgrade item. |
||
set_mapper(index, type, filter) |
Sets the module filter at the given index for this upgrade item. |
|
Sets the module filter at the given index for this upgrade item. |
||
get_blueprint_entity_count() | → uint |
Gets the number of entities in this blueprint item. |
Gets the number of entities in this blueprint item. |
||
get_blueprint_entity_tags(index) | → Tags |
Gets the tags for the given blueprint entity index in this blueprint item. |
Gets the tags for the given blueprint entity index in this blueprint item. |
||
set_blueprint_entity_tags(index, tags) |
Sets the tags on the given blueprint entity index in this blueprint item. |
|
Sets the tags on the given blueprint entity index in this blueprint item. |
||
get_blueprint_entity_tag(index, tag) | → AnyBasic? |
Gets the given tag on the given blueprint entity index in this blueprint item. |
Gets the given tag on the given blueprint entity index in this blueprint item. |
||
set_blueprint_entity_tag(index, tag, value) |
Sets the given tag on the given blueprint entity index in this blueprint item. |
|
Sets the given tag on the given blueprint entity index in this blueprint item. |
||
create_grid() | → LuaEquipmentGrid |
Creates the equipment grid for this item if it doesn't exist and this is an item-with-entity-data that supports equipment grids. |
Creates the equipment grid for this item if it doesn't exist and this is an item-with-entity-data that supports equipment grids. |
||
help() | → string |
All methods and properties that this object supports. |
All methods and properties that this object supports. |
||
valid_for_read [R] | :: boolean |
Is this valid for reading? |
Is this valid for reading? |
||
prototype [R] | :: LuaItemPrototype |
Prototype of the item held in this stack. |
Prototype of the item held in this stack. |
||
name [R] | :: string |
Prototype name of the item held in this stack. |
Prototype name of the item held in this stack. |
||
type [R] | :: string |
Type of the item prototype. |
Type of the item prototype. |
||
count [RW] | :: uint |
Number of items in this stack. |
Number of items in this stack. |
||
grid [R] | :: LuaEquipmentGrid? |
The equipment grid of this item, if any. |
The equipment grid of this item, if any. |
||
health [RW] | :: float |
How much health the item has, as a number in range [0, 1]. |
How much health the item has, as a number in range [0, 1]. |
||
durability [RW] | :: double? |
Durability of the contained item. |
Durability of the contained item. |
||
ammo [RW] | :: uint |
Number of bullets left in the magazine. |
Number of bullets left in the magazine. |
||
blueprint_icons [RW] | :: array[BlueprintSignalIcon]? |
Icons of this blueprint item, blueprint book, deconstruction item or upgrade planner. |
Icons of this blueprint item, blueprint book, deconstruction item or upgrade planner. |
||
blueprint_snap_to_grid [RW] | :: TilePosition? |
The snapping grid size in this blueprint item. |
The snapping grid size in this blueprint item. |
||
blueprint_position_relative_to_grid [RW] | :: TilePosition? |
The offset from the absolute grid. |
The offset from the absolute grid. |
||
blueprint_absolute_snapping [RW] | :: boolean |
If absolute snapping is enabled on this blueprint item. |
If absolute snapping is enabled on this blueprint item. |
||
label [RW] | :: string? |
The current label for this item, if any. |
The current label for this item, if any. |
||
label_color [RW] | :: Color? |
The current label color for this item, if any. |
The current label color for this item, if any. |
||
allow_manual_label_change [RW] | :: boolean |
Whether the label for this item can be manually changed. |
Whether the label for this item can be manually changed. |
||
cost_to_build [R] | :: dictionary[string → uint] |
Raw materials required to build this blueprint. |
Raw materials required to build this blueprint. |
||
extends_inventory [RW] | :: boolean |
If this item extends the inventory it resides in (provides its contents for counts, crafting, insertion). |
If this item extends the inventory it resides in (provides its contents for counts, crafting, insertion). |
||
prioritize_insertion_mode [RW] | :: string |
The insertion mode priority this ItemWithInventory uses when items are inserted into an inventory it resides in. |
The insertion mode priority this ItemWithInventory uses when items are inserted into an inventory it resides in. |
||
default_icons [R] | :: array[BlueprintItemIcon] |
The default icons for a blueprint item. |
The default icons for a blueprint item. |
||
tags [RW] | :: Tags |
|
custom_description [RW] | :: LocalisedString |
The custom description this item-with-tags. |
The custom description this item-with-tags. |
||
entity_filters [RW] | :: array[string] |
The entity filters for this deconstruction item. |
The entity filters for this deconstruction item. |
||
tile_filters [RW] | :: array[string] |
The tile filters for this deconstruction item. |
The tile filters for this deconstruction item. |
||
entity_filter_mode [RW] | :: defines.deconstruction_item.entity_filter_mode |
The blacklist/whitelist entity filter mode for this deconstruction item. |
The blacklist/whitelist entity filter mode for this deconstruction item. |
||
tile_filter_mode [RW] | :: defines.deconstruction_item.tile_filter_mode |
The blacklist/whitelist tile filter mode for this deconstruction item. |
The blacklist/whitelist tile filter mode for this deconstruction item. |
||
tile_selection_mode [RW] | :: defines.deconstruction_item.tile_selection_mode |
The tile selection mode for this deconstruction item. |
The tile selection mode for this deconstruction item. |
||
trees_and_rocks_only [RW] | :: boolean |
If this deconstruction item is set to allow trees and rocks only. |
If this deconstruction item is set to allow trees and rocks only. |
||
entity_filter_count [R] | :: uint |
The number of entity filters this deconstruction item supports. |
The number of entity filters this deconstruction item supports. |
||
tile_filter_count [R] | :: uint |
The number of tile filters this deconstruction item supports. |
The number of tile filters this deconstruction item supports. |
||
active_index [RW] | :: uint? |
The active blueprint index for this blueprint book. |
The active blueprint index for this blueprint book. |
||
item_number [R] | :: uint? |
The unique identifier for this item , if any. |
The unique identifier for this item , if any. |
||
connected_entity [RW] | :: LuaEntity? |
If this item is a spidertron remote that has a spidertron bound to it, it returns the connected spider-vehicle entity. |
If this item is a spidertron remote that has a spidertron bound to it, it returns the connected spider-vehicle entity. |
||
is_blueprint [R] | :: boolean |
If this is a blueprint item. |
If this is a blueprint item. |
||
is_blueprint_book [R] | :: boolean |
If this is a blueprint book item. |
If this is a blueprint book item. |
||
is_module [R] | :: boolean |
If this is a module item. |
If this is a module item. |
||
is_tool [R] | :: boolean |
If this is a tool item. |
If this is a tool item. |
||
is_mining_tool [R] | :: boolean |
If this is a mining tool item. |
If this is a mining tool item. |
||
is_armor [R] | :: boolean |
If this is an armor item. |
If this is an armor item. |
||
is_repair_tool [R] | :: boolean |
If this is a repair tool item. |
If this is a repair tool item. |
||
is_item_with_label [R] | :: boolean |
If this is an item with label item. |
If this is an item with label item. |
||
is_item_with_inventory [R] | :: boolean |
If this is an item with inventory item. |
If this is an item with inventory item. |
||
is_item_with_entity_data [R] | :: boolean |
If this is an item with entity data item. |
If this is an item with entity data item. |
||
is_selection_tool [R] | :: boolean |
If this is a selection tool item. |
If this is a selection tool item. |
||
is_item_with_tags [R] | :: boolean |
If this is an item with tags item. |
If this is an item with tags item. |
||
is_deconstruction_item [R] | :: boolean |
If this is a deconstruction tool item. |
If this is a deconstruction tool item. |
||
is_upgrade_item [R] | :: boolean |
If this is a upgrade item. |
If this is a upgrade item. |
||
valid [R] | :: boolean |
Is this object valid? |
Is this object valid? |
||
object_name [R] | :: string |
The class name of this object. |
The class name of this object. |
Is this blueprint item setup? I.e. is it a non-empty blueprint?
The entities in this blueprint.
Set new entities to be a part of this blueprint.
entities | :: array[BlueprintEntity] |
The new blueprint entities. |
The new blueprint entities. |
Add ammo to this ammo item.
amount | :: float |
Amount of ammo to add. |
Amount of ammo to add. |
Remove ammo from this ammo item.
amount | :: float |
Amount of ammo to remove. |
Amount of ammo to remove. |
Add durability to this tool item.
amount | :: double |
Amount of durability to add. |
Amount of durability to add. |
Remove durability from this tool item.
amount | :: double |
Amount of durability to remove. |
Amount of durability to remove. |
Would a call to LuaItemStack::set_stack succeed?
stack | :: ItemStackIdentification? |
Stack that would be set, possibly |
Stack that would be set, possibly |
Set this item stack to another item stack.
stack | :: ItemStackIdentification? |
Item stack to set it to. Omitting this parameter or passing |
Item stack to set it to. Omitting this parameter or passing |
→ boolean |
Whether the stack was set successfully. Returns |
Transfers the given item stack into this item stack.
stack | :: ItemStackIdentification |
|
→ boolean |
|
Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string.
→ string |
The exported string |
Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string.
data | :: string |
The string to import |
The string to import |
→ int |
0 if the import succeeded with no errors. -1 if the import succeeded with errors. 1 if the import failed. |
Swaps this item stack with the given item stack if allowed.
stack | :: LuaItemStack |
|
→ boolean |
Whether the 2 stacks were swapped successfully. |
A list of the tiles in this blueprint.
Set specific tiles in this blueprint.
tiles | :: array[Tile] |
Tiles to be a part of the blueprint. |
Tiles to be a part of the blueprint. |
Access the inner inventory of an item.
inventory | :: defines.inventory |
Index of the inventory to access, which can only be defines.inventory.item_main. |
Index of the inventory to access, which can only be defines.inventory.item_main. |
→ LuaInventory? |
|
surface | :: SurfaceIdentification |
Surface to build on |
Surface to build on |
||
force | :: ForceIdentification |
Force to use for the building |
Force to use for the building |
||
position | :: MapPosition |
The position to build at |
The position to build at |
||
force_build | :: boolean? |
When true, anything that can be built is else nothing is built if any one thing can't be built |
When true, anything that can be built is else nothing is built if any one thing can't be built |
||
direction | :: defines.direction? |
The direction to use when building |
The direction to use when building |
||
skip_fog_of_war | :: boolean? |
If chunks covered by fog-of-war are skipped. |
If chunks covered by fog-of-war are skipped. |
||
by_player | :: PlayerIdentification? |
The player to use if any. If provided defines.events.on_built_entity will also be fired on successful entity creation. |
The player to use if any. If provided defines.events.on_built_entity will also be fired on successful entity creation. |
||
raise_built | :: boolean? |
If true; defines.events.script_raised_built will be fired on successful entity creation. Note: this is ignored if by_player is provided. |
If true; defines.events.script_raised_built will be fired on successful entity creation. Note: this is ignored if by_player is provided. |
→ array[LuaEntity] |
Array of created ghosts |
Built entities can be come invalid between the building of the blueprint and the function returning if by_player or raise_built is used and one of those events invalidates the entity.
Deconstruct the given area with this deconstruction item.
surface | :: SurfaceIdentification |
Surface to deconstruct on |
Surface to deconstruct on |
||
force | :: ForceIdentification |
Force to use for the deconstruction |
Force to use for the deconstruction |
||
area | :: BoundingBox |
The area to deconstruct |
The area to deconstruct |
||
skip_fog_of_war | :: boolean? |
If chunks covered by fog-of-war are skipped. |
If chunks covered by fog-of-war are skipped. |
||
by_player | :: PlayerIdentification? |
The player to use if any. |
The player to use if any. |
Cancel deconstruct the given area with this deconstruction item.
surface | :: SurfaceIdentification |
Surface to cancel deconstruct on |
Surface to cancel deconstruct on |
||
force | :: ForceIdentification |
Force to use for canceling deconstruction |
Force to use for canceling deconstruction |
||
area | :: BoundingBox |
The area to deconstruct |
The area to deconstruct |
||
skip_fog_of_war | :: boolean? |
If chunks covered by fog-of-war are skipped. |
If chunks covered by fog-of-war are skipped. |
||
by_player | :: PlayerIdentification? |
The player to use if any. |
The player to use if any. |
Sets up this blueprint using the found blueprintable entities/tiles on the surface.
surface | :: SurfaceIdentification |
Surface to create from |
Surface to create from |
||
force | :: ForceIdentification |
Force to use for the creation |
Force to use for the creation |
||
area | :: BoundingBox |
The bounding box |
The bounding box |
||
always_include_tiles | :: boolean? |
When true, blueprintable tiles are always included in the blueprint. When false they're only included if no entities exist in the setup area. |
When true, blueprintable tiles are always included in the blueprint. When false they're only included if no entities exist in the setup area. |
||
include_entities | :: boolean? |
When true, entities are included in the blueprint. Defaults to true. |
When true, entities are included in the blueprint. Defaults to true. |
||
include_modules | :: boolean? |
When true, modules are included in the blueprint. Defaults to true. |
When true, modules are included in the blueprint. Defaults to true. |
||
include_station_names | :: boolean? |
When true, station names are included in the blueprint. Defaults to false. |
When true, station names are included in the blueprint. Defaults to false. |
||
include_trains | :: boolean? |
When true, trains are included in the blueprint. Defaults to false. |
When true, trains are included in the blueprint. Defaults to false. |
||
include_fuel | :: boolean? |
When true, train fuel is included in the blueprint, Defaults to true. |
When true, train fuel is included in the blueprint, Defaults to true. |
→ dictionary[uint → LuaEntity] |
The blueprint entity index to source entity mapping. |
Gets the tag with the given name or returns nil
if it doesn't exist.
tag_name | :: string |
|
Gets the entity filter at the given index for this deconstruction item.
index | :: uint |
|
Sets the entity filter at the given index for this deconstruction item.
index | :: uint |
|
filter | :: string or LuaEntityPrototype or LuaEntity or nil |
Writing |
Writing |
→ boolean |
Whether the new filter was successfully set (ie. was valid). |
Gets the tile filter at the given index for this deconstruction item.
index | :: uint |
|
Sets the tile filter at the given index for this deconstruction item.
index | :: uint |
|
filter | :: string or LuaTilePrototype or LuaTile |
Setting to nil erases the filter. |
Setting to nil erases the filter. |
→ boolean |
Whether the new filter was successfully set (ie. was valid). |
Clears all settings/filters on this deconstruction item resetting it to default values.
Clears all settings/filters on this upgrade item resetting it to default values.
Sets the module filter at the given index for this upgrade item.
index | :: uint |
The index of the mapper to set. |
The index of the mapper to set. |
||
type | :: string |
|
|
||
filter | :: UpgradeFilter |
The filter to set or |
The filter to set or |
Gets the number of entities in this blueprint item.
Sets the given tag on the given blueprint entity index in this blueprint item.
index | :: uint |
The entity index. |
The entity index. |
||
tag | :: string |
The tag to set. |
The tag to set. |
||
value | :: AnyBasic |
The tag value to set or |
The tag value to set or |
Creates the equipment grid for this item if it doesn't exist and this is an item-with-entity-data that supports equipment grids.
All methods and properties that this object supports.
Is 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.
Prototype of the item held in this stack.
Prototype name of the item held in this stack.
Type of the item prototype.
Number of items in this stack.
The equipment grid of this item, if any.
How much health the item has, as a number in range [0, 1].
Durability of the contained item. Automatically capped at the item's maximum durability.
Number of bullets left in the magazine.
Icons of this blueprint item, blueprint book, deconstruction item or upgrade planner. An item that doesn't have icons returns nil
on read and throws error on write.
The snapping grid size in this blueprint item. nil
if snapping is not enabled.
The offset from the absolute grid. nil
if absolute snapping is not enabled.
If absolute snapping is enabled on this blueprint item.
The current label for this item, if any.
The current label color for this item, if any.
Whether the label for this item can be manually changed. When false the label can only be changed through the API.
Raw materials required to build this blueprint. Result is a dictionary mapping each item prototype name to the required count.
If this item extends the inventory it resides in (provides its contents for counts, crafting, insertion). Only callable on items with inventories.
The insertion mode priority this ItemWithInventory uses when items are inserted into an inventory it resides in. Only callable on items with inventories.
The default icons for a blueprint item.
The custom description this item-with-tags. This is shown over the normal item description if this is set to a non-empty value.
The entity filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. All strings in this array must be entity prototype names that don't have the "not-deconstructable"
flag set and are either a cliff
or marked as minable
.
The tile filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. All strings in this array must be tile prototype names.
The blacklist/whitelist entity filter mode for this deconstruction item.
The blacklist/whitelist tile filter mode for this deconstruction item.
The tile selection mode for this deconstruction item.
If this deconstruction item is set to allow trees and rocks only.
The number of entity filters this deconstruction item supports.
The number of tile filters this deconstruction item supports.
The active blueprint index for this blueprint book. nil
if this blueprint book is empty.
The unique identifier for this item , if any. Note that this ID stays the same no matter where the item is moved to.
Only these types of items have unique IDs:
- "armor"
- "spidertron-remote"
- "selection-tool"
- "copy-paste-tool"
- "upgrade-item"
- "deconstruction-item"
- "blueprint"
- "blueprint-book"
- "item-with-entity-data"
- "item-with-inventory"
- "item-with-tags"
If this item is a spidertron remote that has a spidertron bound to it, it returns the connected spider-vehicle entity.
If this is a blueprint item.
If this is a blueprint book item.
If this is a module item.
If this is a tool item.
If this is a mining tool item.
If this is an armor item.
If this is a repair tool item.
If this is an item with label item.
If this is an item with inventory item.
If this is an item with entity data item.
If this is a selection tool item.
If this is an item with tags item.
If this is a deconstruction tool item.
If this is a upgrade item.
Is 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.
The 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.