Common methods related to usage of item with data. It is useful when LuaItemStack contains item with data or in general with LuaItem as it can only point at an item with data.
booleanunknownfalseIf this is a blueprint item.
booleanunknownfalseIf this is a blueprint book item.
booleanunknownfalseIf this is an item with label item.
booleanunknownfalseIf this is an item with inventory item.
booleanunknownfalseIf this is an item with entity data item.
booleanunknownfalseIf this is a selection tool item.
booleanunknownfalseIf this is an item with tags item.
booleanunknownfalseIf this is a deconstruction tool item.
booleanunknownfalseIf this is a upgrade item.
booleanunknownfalseIf this is a tool item.
booleanunknownfalseIf this is an ammo item.
booleanunknownfalseIf this is an armor item.
booleanunknownfalseIf this is a repair tool item.
uint64unknowntrueThe unique identifier for this item, if any. Note that this ID stays the same no matter where the item is moved to.
Array<BlueprintSignalIcon>Array<BlueprintSignalIcon>trueIcons 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.
LuaEquipmentGridunknowntrueThe equipment grid of this item, if any.
ItemLocationDataunknownfalseThe location of this item if it can be found.
TilePositionTilePositiontrueThe snapping grid size in this blueprint item. nil if snapping is not enabled.
TilePositionTilePositiontrueThe offset from the absolute grid. nil if absolute snapping is not enabled.
booleanbooleanfalseIf absolute snapping is enabled on this blueprint item.
stringstringfalseThe description for this blueprint or blueprint book
ItemWithQualityCountsunknownfalseList of raw materials required to build this blueprint.
Array<BlueprintSignalIcon>unknownfalseThe default icons for a blueprint item.
uint32uint32trueThe active blueprint index for this blueprint book. nil if this blueprint book is empty.
stringstringtrueThe current label for this item, if any.
ColorColortrueThe current label color for this item, if any.
booleanbooleanfalseWhether the label for this item can be manually changed. When false the label can only be changed through the API.
stringstringtrueIf this is an item with entity data, get the stored entity label.
ColorColortrueIf this is an item with entity data, get the stored entity color.
LogisticSectionsLogisticSectionsfalseIf this is an item with entity data, get the stored logistic filters.
booleanbooleanfalseIf this is an item with entity data, get the stored request from buffer state.
booleanbooleanfalseIf this is an item with entity data, get the stored vehicle logistics enabled state.
booleanbooleanfalseIf this is an item with entity data, get the stored enable logistics while moving state.
booleanbooleanfalseIf this is an item with entity data, get the stored driver is gunner state.
booleanbooleanfalseIf this is an item with entity data, get the stored auto target without gunner state.
booleanbooleanfalseIf this is an item with entity data, get the stored auto target with gunner state.
TagsTagsfalseLocalisedStringLocalisedStringfalseThe custom description this item-with-tags. This is shown over the normal item description if this is set to a non-empty value.
uint32unknownfalseThe number of entity filters this deconstruction item supports.
Array<ItemFilter>Array<ItemFilter>falseThe entity filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. All prototypes in this array must not have the "not-deconstructable" flag set and are either a cliff or marked as minable.
uint32unknownfalseThe number of tile filters this deconstruction item supports.
Array<TileID>Array<TileID>falseThe tile filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. Reading filters always returns an array of strings which are the tile prototype names.
defines.deconstruction_item.entity_filter_modedefines.deconstruction_item.entity_filter_modefalseThe blacklist/whitelist entity filter mode for this deconstruction item.
defines.deconstruction_item.tile_filter_modedefines.deconstruction_item.tile_filter_modefalseThe blacklist/whitelist tile filter mode for this deconstruction item.
defines.deconstruction_item.tile_selection_modedefines.deconstruction_item.tile_selection_modefalseThe tile selection mode for this deconstruction item.
booleanbooleanfalseIf this deconstruction item is set to allow trees and rocks only.
uint32unknownfalseThe current count of mappers in the upgrade item.
doubledoublefalseDurability of the contained item. Automatically capped at the item's maximum durability.
uint32uint32falseNumber of bullets left in the magazine.
LuaItemCommon.get_inventory(inventory: defines.inventory) -> LuaInventory?
itemCommon.get_inventory(inventory)
takes_table: falsetable_optional: falseAccess the inner inventory of an item.
inventory: defines.inventory — Index of the inventory to access, which can only be defines.inventory.item_main.LuaInventory? — nil if there is no inventory with the given index.LuaItemCommon.clear_blueprint()
itemCommon.clear_blueprint()
takes_table: falsetable_optional: falseClears this blueprint item.
LuaItemCommon.is_blueprint_setup() -> boolean
itemCommon.is_blueprint_setup()
takes_table: falsetable_optional: falseIs this blueprint item setup? I.e. is it a non-empty blueprint?
booleanLuaItemCommon.build_blueprint{ surface: SurfaceIdentification, force: ForceID, position: MapPosition, direction?: defines.direction, build_mode?: defines.build_mode, skip_fog_of_war?: boolean, by_player?: PlayerIdentification, raise_built?: boolean } -> Array<LuaEntity>
itemCommon.build_blueprint{ surface=surface, force=force, position=position }
takes_table: truetable_optional: falseBuild this blueprint at the given location.
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.
surface: SurfaceIdentification — Surface to build onforce: ForceID — Force to use for the buildingposition: MapPosition — The position to build atdirection?: defines.direction — The direction to use when buildingbuild_mode?: defines.build_mode — If normal, blueprint will not be built if any one thing can't be built. If forced, anything that can be built is built and obstructing nature entities will be deconstructed. If superforced, all obstructions will be deconstructed and the blueprint will be built.skip_fog_of_war?: boolean — 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.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.Array<LuaEntity> — Array of created ghostsLuaItemCommon.create_blueprint{ surface: SurfaceIdentification, force: ForceID, area: BoundingBox, always_include_tiles?: boolean, include_entities?: boolean, include_modules?: boolean, include_station_names?: boolean, include_trains?: boolean, include_fuel?: boolean } -> Dict<uint32, LuaEntity>
itemCommon.create_blueprint{ surface=surface, force=force, area=area }
takes_table: truetable_optional: falseSets up this blueprint using the found blueprintable entities/tiles on the surface.
surface: SurfaceIdentification — Surface to create fromforce: ForceID — Force to use for the creationarea: BoundingBox — The bounding boxalways_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. Defaults to false.include_entities?: boolean — 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.include_station_names?: boolean — 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.include_fuel?: boolean — When true, train fuel is included in the blueprint, Defaults to true.Dict<uint32, LuaEntity> — The blueprint entity index to source entity mapping.LuaItemCommon.get_blueprint_entity_tags(index: uint32) -> Tags
itemCommon.get_blueprint_entity_tags(index)
takes_table: falsetable_optional: falseGets the tags for the given blueprint entity index in this blueprint item.
index: uint32TagsLuaItemCommon.set_blueprint_entity_tags(index: uint32, tags: Tags)
itemCommon.set_blueprint_entity_tags(index, tags)
takes_table: falsetable_optional: falseSets the tags on the given blueprint entity index in this blueprint item.
index: uint32 — The entity indextags: TagsLuaItemCommon.get_blueprint_entity_tag(index: uint32, tag: string) -> AnyBasic?
itemCommon.get_blueprint_entity_tag(index, tag)
takes_table: falsetable_optional: falseGets the given tag on the given blueprint entity index in this blueprint item.
index: uint32 — The entity index.tag: string — The tag to get.AnyBasic?LuaItemCommon.set_blueprint_entity_tag(index: uint32, tag: string, value: AnyBasic)
itemCommon.set_blueprint_entity_tag(index, tag, value)
takes_table: falsetable_optional: falseSets the given tag on the given blueprint entity index in this blueprint item.
index: uint32 — The entity index.tag: string — The tag to set.value: AnyBasic — The tag value to set or nil to clear the tag.LuaItemCommon.get_blueprint_entities() -> Array<BlueprintEntity>?
itemCommon.get_blueprint_entities()
takes_table: falsetable_optional: falseThe entities in this blueprint.
Array<BlueprintEntity>?LuaItemCommon.set_blueprint_entities(entities: Array<BlueprintEntity>)
itemCommon.set_blueprint_entities(entities)
takes_table: falsetable_optional: falseSet new entities to be a part of this blueprint.
entities: Array<BlueprintEntity> — The new blueprint entities.LuaItemCommon.get_blueprint_tiles() -> Array<Tile>?
itemCommon.get_blueprint_tiles()
takes_table: falsetable_optional: falseA list of the tiles in this blueprint.
Array<Tile>?LuaItemCommon.set_blueprint_tiles(tiles: Array<Tile>)
itemCommon.set_blueprint_tiles(tiles)
takes_table: falsetable_optional: falseSet specific tiles in this blueprint.
tiles: Array<Tile> — Tiles to be a part of the blueprint.LuaItemCommon.get_blueprint_entity_count() -> uint32
itemCommon.get_blueprint_entity_count()
takes_table: falsetable_optional: falseGets the number of entities in this blueprint item.
uint32LuaItemCommon.get_tag(tag_name: string) -> AnyBasic?
itemCommon.get_tag(tag_name)
takes_table: falsetable_optional: falseGets the tag with the given name or returns nil if it doesn't exist.
tag_name: stringAnyBasic?LuaItemCommon.set_tag(tag_name: string, tag: AnyBasic)
itemCommon.set_tag(tag_name, tag)
takes_table: falsetable_optional: falseSets the tag with the given name and value.
tag_name: stringtag: AnyBasicLuaItemCommon.remove_tag(tag: string) -> boolean
itemCommon.remove_tag(tag)
takes_table: falsetable_optional: falseRemoves a tag with the given name.
tag: stringboolean — If the tag existed and was removed.LuaItemCommon.get_entity_filter(index: uint32) -> ItemFilter?
itemCommon.get_entity_filter(index)
takes_table: falsetable_optional: falseGets the entity filter at the given index for this deconstruction item.
index: uint32ItemFilter?LuaItemCommon.set_entity_filter(index: uint32, filter: ItemFilter | nil) -> boolean
itemCommon.set_entity_filter(index, filter)
takes_table: falsetable_optional: falseSets the entity filter at the given index for this deconstruction item.
index: uint32filter: ItemFilter | nil — Writing nil removes the filter.boolean — Whether the new filter was successfully set (meaning it was valid).LuaItemCommon.get_tile_filter(index: uint32) -> string?
itemCommon.get_tile_filter(index)
takes_table: falsetable_optional: falseGets the tile filter at the given index for this deconstruction item.
index: uint32string?LuaItemCommon.set_tile_filter(index: uint32, filter: string | LuaTilePrototype | LuaTile | nil) -> boolean
itemCommon.set_tile_filter(index, filter)
takes_table: falsetable_optional: falseSets the tile filter at the given index for this deconstruction item.
index: uint32filter: string | LuaTilePrototype | LuaTile | nil — Writing nil removes the filter.boolean — Whether the new filter was successfully set (meaning it was valid).LuaItemCommon.deconstruct_area{ surface: SurfaceIdentification, force: ForceID, area: BoundingBox, skip_fog_of_war?: boolean, by_player?: PlayerIdentification, super_forced?: boolean }
itemCommon.deconstruct_area{ surface=surface, force=force, area=area }
takes_table: truetable_optional: falseDeconstruct the given area with this deconstruction item.
surface: SurfaceIdentification — Surface to deconstruct onforce: ForceID — Force to use for the deconstructionarea: BoundingBox — The area to deconstructskip_fog_of_war?: boolean — If chunks covered by fog-of-war are skipped. Defaults to false.by_player?: PlayerIdentification — The player to use if any.super_forced?: boolean — If the deconstruction is super-forced. Defaults to false.LuaItemCommon.cancel_deconstruct_area{ surface: SurfaceIdentification, force: ForceID, area: BoundingBox, skip_fog_of_war?: boolean, by_player?: PlayerIdentification, super_forced?: boolean }
itemCommon.cancel_deconstruct_area{ surface=surface, force=force, area=area }
takes_table: truetable_optional: falseCancel deconstruct the given area with this deconstruction item.
surface: SurfaceIdentification — Surface to cancel deconstruct onforce: ForceID — Force to use for canceling deconstructionarea: BoundingBox — The area to deconstructskip_fog_of_war?: boolean — If chunks covered by fog-of-war are skipped. Defaults to false.by_player?: PlayerIdentification — The player to use if any.super_forced?: boolean — If the cancel deconstruction is super-forced. Defaults to false.LuaItemCommon.clear_deconstruction_item()
itemCommon.clear_deconstruction_item()
takes_table: falsetable_optional: falseClears all settings/filters on this deconstruction item resetting it to default values.
LuaItemCommon.clear_upgrade_item()
itemCommon.clear_upgrade_item()
takes_table: falsetable_optional: falseClears all settings/filters on this upgrade item resetting it to default values.
LuaItemCommon.get_mapper(index: uint32, type: "from" | "to") -> UpgradeMapperSource | UpgradeMapperDestination?
itemCommon.get_mapper(index, type)
takes_table: falsetable_optional: falseGets the filter at the given index for this upgrade item. Note that sources ("from" type) that are undefined will read as {type = "item"}, while destinations ("to" type) that are undefined will read as nil.
In contrast to LuaItemCommon::set_mapper, indices past the upgrade item's current size are considered to be out of bounds.
index: uint32 — The index of the mapper to read.type: "from" | "to"UpgradeMapperSource | UpgradeMapperDestination?LuaItemCommon.set_mapper(index: uint32, type: "from" | "to", mapper: UpgradeMapperSource | UpgradeMapperDestination | nil)
itemCommon.set_mapper(index, type, mapper)
takes_table: falsetable_optional: falseSets the module filter at the given index for this upgrade item.
In contrast to LuaItemCommon::get_mapper, indices past the upgrade item's current size are valid and expand the list of mappings accordingly, if within reasonable bounds.
index: uint32 — The index of the mapper to set.type: "from" | "to"mapper: UpgradeMapperSource | UpgradeMapperDestination | nil — The mapper to set. Set nil to clear the mapper.