Home

LuaItemCommon

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.

Attributes

is_blueprint

If this is a blueprint item.

is_blueprint_book

If this is a blueprint book item.

is_item_with_label

If this is an item with label item.

is_item_with_inventory

If this is an item with inventory item.

is_item_with_entity_data

If this is an item with entity data item.

is_selection_tool

If this is a selection tool item.

is_item_with_tags

If this is an item with tags item.

is_deconstruction_item

If this is a deconstruction tool item.

is_upgrade_item

If this is a upgrade item.

is_tool

If this is a tool item.

is_ammo

If this is an ammo item.

is_armor

If this is an armor item.

is_repair_tool

If this is a repair tool item.

item_number

The unique identifier for this item, if any. Note that this ID stays the same no matter where the item is moved to.

preview_icons

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.

grid

The equipment grid of this item, if any.

owner_location

The location of this item if it can be found.

blueprint_snap_to_grid

The snapping grid size in this blueprint item. nil if snapping is not enabled.

blueprint_position_relative_to_grid

The offset from the absolute grid. nil if absolute snapping is not enabled.

blueprint_absolute_snapping

If absolute snapping is enabled on this blueprint item.

blueprint_description

The description for this blueprint or blueprint book

cost_to_build

List of raw materials required to build this blueprint.

default_icons

The default icons for a blueprint item.

active_index

The active blueprint index for this blueprint book. nil if this blueprint book is empty.

label

The current label for this item, if any.

label_color

The current label color for this item, if any.

allow_manual_label_change

Whether the label for this item can be manually changed. When false the label can only be changed through the API.

entity_label

If this is an item with entity data, get the stored entity label.

entity_color

If this is an item with entity data, get the stored entity color.

entity_logistic_sections

If this is an item with entity data, get the stored logistic filters.

entity_request_from_buffers

If this is an item with entity data, get the stored request from buffer state.

entity_logistics_enabled

If this is an item with entity data, get the stored vehicle logistics enabled state.

entity_enable_logistics_while_moving

If this is an item with entity data, get the stored enable logistics while moving state.

entity_driver_is_gunner

If this is an item with entity data, get the stored driver is gunner state.

entity_auto_target_without_gunner

If this is an item with entity data, get the stored auto target without gunner state.

entity_auto_target_with_gunner

If this is an item with entity data, get the stored auto target with gunner state.

tags

custom_description

The custom description this item-with-tags. This is shown over the normal item description if this is set to a non-empty value.

entity_filter_count

The number of entity filters this deconstruction item supports.

entity_filters

The 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.

tile_filter_count

The number of tile filters this deconstruction item supports.

tile_filters

The 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.

entity_filter_mode

The blacklist/whitelist entity filter mode for this deconstruction item.

tile_filter_mode

The blacklist/whitelist tile filter mode for this deconstruction item.

tile_selection_mode

The tile selection mode for this deconstruction item.

trees_and_rocks_only

If this deconstruction item is set to allow trees and rocks only.

mapper_count

The current count of mappers in the upgrade item.

durability

Durability of the contained item. Automatically capped at the item's maximum durability.

ammo

Number of bullets left in the magazine.

Methods

get_inventory

LuaItemCommon.get_inventory(inventory: defines.inventory) -> LuaInventory?

Call As

itemCommon.get_inventory(inventory)

Call Convention

Access the inner inventory of an item.

Parameters

Returns

clear_blueprint

LuaItemCommon.clear_blueprint()

Call As

itemCommon.clear_blueprint()

Call Convention

Clears this blueprint item.

is_blueprint_setup

LuaItemCommon.is_blueprint_setup() -> boolean

Call As

itemCommon.is_blueprint_setup()

Call Convention

Is this blueprint item setup? I.e. is it a non-empty blueprint?

Returns

build_blueprint

LuaItemCommon.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>

Call As

itemCommon.build_blueprint{ surface=surface, force=force, position=position }

Call Convention

Build 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.

Parameters

Returns

create_blueprint

LuaItemCommon.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>

Call As

itemCommon.create_blueprint{ surface=surface, force=force, area=area }

Call Convention

Sets up this blueprint using the found blueprintable entities/tiles on the surface.

Parameters

Returns

get_blueprint_entity_tags

LuaItemCommon.get_blueprint_entity_tags(index: uint32) -> Tags

Call As

itemCommon.get_blueprint_entity_tags(index)

Call Convention

Gets the tags for the given blueprint entity index in this blueprint item.

Parameters

Returns

set_blueprint_entity_tags

LuaItemCommon.set_blueprint_entity_tags(index: uint32, tags: Tags)

Call As

itemCommon.set_blueprint_entity_tags(index, tags)

Call Convention

Sets the tags on the given blueprint entity index in this blueprint item.

Parameters

get_blueprint_entity_tag

LuaItemCommon.get_blueprint_entity_tag(index: uint32, tag: string) -> AnyBasic?

Call As

itemCommon.get_blueprint_entity_tag(index, tag)

Call Convention

Gets the given tag on the given blueprint entity index in this blueprint item.

Parameters

Returns

set_blueprint_entity_tag

LuaItemCommon.set_blueprint_entity_tag(index: uint32, tag: string, value: AnyBasic)

Call As

itemCommon.set_blueprint_entity_tag(index, tag, value)

Call Convention

Sets the given tag on the given blueprint entity index in this blueprint item.

Parameters

get_blueprint_entities

LuaItemCommon.get_blueprint_entities() -> Array<BlueprintEntity>?

Call As

itemCommon.get_blueprint_entities()

Call Convention

The entities in this blueprint.

Returns

set_blueprint_entities

LuaItemCommon.set_blueprint_entities(entities: Array<BlueprintEntity>)

Call As

itemCommon.set_blueprint_entities(entities)

Call Convention

Set new entities to be a part of this blueprint.

Parameters

get_blueprint_tiles

LuaItemCommon.get_blueprint_tiles() -> Array<Tile>?

Call As

itemCommon.get_blueprint_tiles()

Call Convention

A list of the tiles in this blueprint.

Returns

set_blueprint_tiles

LuaItemCommon.set_blueprint_tiles(tiles: Array<Tile>)

Call As

itemCommon.set_blueprint_tiles(tiles)

Call Convention

Set specific tiles in this blueprint.

Parameters

get_blueprint_entity_count

LuaItemCommon.get_blueprint_entity_count() -> uint32

Call As

itemCommon.get_blueprint_entity_count()

Call Convention

Gets the number of entities in this blueprint item.

Returns

get_tag

LuaItemCommon.get_tag(tag_name: string) -> AnyBasic?

Call As

itemCommon.get_tag(tag_name)

Call Convention

Gets the tag with the given name or returns nil if it doesn't exist.

Parameters

Returns

set_tag

LuaItemCommon.set_tag(tag_name: string, tag: AnyBasic)

Call As

itemCommon.set_tag(tag_name, tag)

Call Convention

Sets the tag with the given name and value.

Parameters

remove_tag

LuaItemCommon.remove_tag(tag: string) -> boolean

Call As

itemCommon.remove_tag(tag)

Call Convention

Removes a tag with the given name.

Parameters

Returns

get_entity_filter

LuaItemCommon.get_entity_filter(index: uint32) -> ItemFilter?

Call As

itemCommon.get_entity_filter(index)

Call Convention

Gets the entity filter at the given index for this deconstruction item.

Parameters

Returns

set_entity_filter

LuaItemCommon.set_entity_filter(index: uint32, filter: ItemFilter | nil) -> boolean

Call As

itemCommon.set_entity_filter(index, filter)

Call Convention

Sets the entity filter at the given index for this deconstruction item.

Parameters

Returns

get_tile_filter

LuaItemCommon.get_tile_filter(index: uint32) -> string?

Call As

itemCommon.get_tile_filter(index)

Call Convention

Gets the tile filter at the given index for this deconstruction item.

Parameters

Returns

set_tile_filter

LuaItemCommon.set_tile_filter(index: uint32, filter: string | LuaTilePrototype | LuaTile | nil) -> boolean

Call As

itemCommon.set_tile_filter(index, filter)

Call Convention

Sets the tile filter at the given index for this deconstruction item.

Parameters

Returns

deconstruct_area

LuaItemCommon.deconstruct_area{ surface: SurfaceIdentification, force: ForceID, area: BoundingBox, skip_fog_of_war?: boolean, by_player?: PlayerIdentification, super_forced?: boolean }

Call As

itemCommon.deconstruct_area{ surface=surface, force=force, area=area }

Call Convention

Deconstruct the given area with this deconstruction item.

Parameters

cancel_deconstruct_area

LuaItemCommon.cancel_deconstruct_area{ surface: SurfaceIdentification, force: ForceID, area: BoundingBox, skip_fog_of_war?: boolean, by_player?: PlayerIdentification, super_forced?: boolean }

Call As

itemCommon.cancel_deconstruct_area{ surface=surface, force=force, area=area }

Call Convention

Cancel deconstruct the given area with this deconstruction item.

Parameters

clear_deconstruction_item

LuaItemCommon.clear_deconstruction_item()

Call As

itemCommon.clear_deconstruction_item()

Call Convention

Clears all settings/filters on this deconstruction item resetting it to default values.

clear_upgrade_item

LuaItemCommon.clear_upgrade_item()

Call As

itemCommon.clear_upgrade_item()

Call Convention

Clears all settings/filters on this upgrade item resetting it to default values.

get_mapper

LuaItemCommon.get_mapper(index: uint32, type: "from" | "to") -> UpgradeMapperSource | UpgradeMapperDestination?

Call As

itemCommon.get_mapper(index, type)

Call Convention

Gets 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.

Parameters

Returns

set_mapper

LuaItemCommon.set_mapper(index: uint32, type: "from" | "to", mapper: UpgradeMapperSource | UpgradeMapperDestination | nil)

Call As

itemCommon.set_mapper(index, type, mapper)

Call Convention

Sets 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.

Parameters