Home

LuaRecord

A reference to a record in the blueprint library. Records in the "my blueprints" shelf are read-only, but records in the "game blueprints" shelf are read/write.

Attributes

valid_for_write

Is this record valid for writing? A record is invalid for write if it is a BlueprintRecord preview or if it is in the "My blueprints" shelf.

type

The type of this blueprint record.

preview_icons

The preview icons for this record.

is_preview

Checks if this record is in a preview state.

is_blueprint_preview

Is this blueprint record a preview? A preview record must be synced by the player before entity and tile data can be read. This property is deprecated in favor of LuaRecord::is_preview and should not be used.

blueprint_snap_to_grid

The snapping grid size in this blueprint. 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.

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

contents

The contents of this BlueprintBookRecord. This is sparse array - it may have gaps, so using # will not be reliable. Use LuaRecord::contents_size or pairs() to iterate this table.

contents_size

The highest populated index in the contents of this BlueprintBookRecord.

entity_filters

The entity filters for this deconstruction planner. 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_filters

The tile filters for this deconstruction planner. 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 planner.

tile_filter_mode

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

tile_selection_mode

The tile selection mode for this deconstruction planner.

trees_and_rocks_only

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

entity_filter_count

The number of entity filters this deconstruction planner supports.

tile_filter_count

The number of tile filters this deconstruction planner supports.

mapper_count

The current count of mappers in the upgrade item.

valid

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.

object_name

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.

Methods

export_record

LuaRecord.export_record() -> string

Call As

record.export_record()

Call Convention

Exports this record to a string.

Returns

clear_blueprint

LuaRecord.clear_blueprint()

Call As

record.clear_blueprint()

Call Convention

Clears this blueprint.

is_blueprint_setup

LuaRecord.is_blueprint_setup() -> boolean

Call As

record.is_blueprint_setup()

Call Convention

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

Returns

build_blueprint

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

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

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

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

LuaRecord.get_blueprint_entity_tags(index: uint32) -> Tags

Call As

record.get_blueprint_entity_tags(index)

Call Convention

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

Parameters

Returns

set_blueprint_entity_tags

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

Call As

record.set_blueprint_entity_tags(index, tags)

Call Convention

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

Parameters

get_blueprint_entity_tag

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

Call As

record.get_blueprint_entity_tag(index, tag)

Call Convention

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

Parameters

Returns

set_blueprint_entity_tag

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

Call As

record.set_blueprint_entity_tag(index, tag, value)

Call Convention

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

Parameters

get_blueprint_entities

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

Call As

record.get_blueprint_entities()

Call Convention

The entities in this blueprint.

Returns

set_blueprint_entities

LuaRecord.set_blueprint_entities(entities: Array<BlueprintEntity>)

Call As

record.set_blueprint_entities(entities)

Call Convention

Set new entities to be a part of this blueprint.

Parameters

get_blueprint_tiles

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

Call As

record.get_blueprint_tiles()

Call Convention

A list of the tiles in this blueprint.

Returns

set_blueprint_tiles

LuaRecord.set_blueprint_tiles(tiles: Array<Tile>)

Call As

record.set_blueprint_tiles(tiles)

Call Convention

Set specific tiles in this blueprint.

Parameters

get_blueprint_entity_count

LuaRecord.get_blueprint_entity_count() -> uint32

Call As

record.get_blueprint_entity_count()

Call Convention

Gets the number of entities in this blueprint blueprint.

Returns

get_active_index

LuaRecord.get_active_index(player: PlayerIdentification) -> uint32

Call As

record.get_active_index(player)

Call Convention

The active index of this BlueprintBookRecord. For records in "my blueprints", the result will be the same regardless of the player, but records in "game blueprints" may have different active indices per player.

Parameters

Returns

get_selected_record

LuaRecord.get_selected_record(player: PlayerIdentification) -> LuaRecord?

Call As

record.get_selected_record(player)

Call Convention

Gets the currently selected record of the book for the given player.

Note: this will return a record even if the book is in a preview state.

Parameters

Returns

get_entity_filter

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

Call As

record.get_entity_filter(index)

Call Convention

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

Parameters

Returns

set_entity_filter

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

Call As

record.set_entity_filter(index, filter)

Call Convention

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

Parameters

Returns

get_tile_filter

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

Call As

record.get_tile_filter(index)

Call Convention

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

Parameters

Returns

set_tile_filter

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

Call As

record.set_tile_filter(index, filter)

Call Convention

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

Parameters

Returns

deconstruct_area

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

Call As

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

Call Convention

Deconstruct the given area with this deconstruction planner.

Parameters

cancel_deconstruct_area

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

Call As

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

Call Convention

Cancel deconstruct the given area with this deconstruction planner.

Parameters

clear_deconstruction_data

LuaRecord.clear_deconstruction_data()

Call As

record.clear_deconstruction_data()

Call Convention

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

clear_upgrade_data

LuaRecord.clear_upgrade_data()

Call As

record.clear_upgrade_data()

Call Convention

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

get_mapper

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

Call As

record.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 LuaRecord::set_mapper, indices past the upgrade item's current size are considered to be out of bounds.

Parameters

Returns

set_mapper

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

Call As

record.set_mapper(index, type, mapper)

Call Convention

Sets the module filter at the given index for this upgrade item.

In contrast to LuaRecord::get_mapper, indices past the upgrade item's current size are valid and expand the list of mappings accordingly, if within reasonable bounds.

Parameters