This is an abstract base class containing the common functionality between LuaPlayer and entities (see LuaEntity). When accessing player-related functions through a LuaEntity, it must refer to a character entity.
LuaSurfaceunknownfalseThe surface this entity is currently on.
uint32unknownfalseUnique index (ID) associated with the surface this entity is currently on.
MapPositionunknownfalseThe current position of the entity.
MapPositionunknownfalseThe current render position of the entity.
booleanunknownfalseIf this player or character entity is flying.
When called on an entity, only valid if this entity is a character.
doubleunknownfalseThe current flight height for this player or character entity.
When called on an entity, only valid if this entity is a character.
LuaEntityunknowntrueThe vehicle the player is currently sitting in.
LuaEntityunknowntrueThe cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.
LuaEntityunknowntrueThe space platform hub the player is currently sitting in.
LuaForceForceIDfalseThe force of this entity. Reading will always give a LuaForce, but it is possible to assign either string, uint8 or LuaForce to this attribute to change the force.
uint32unknownfalseUnique index (ID) associated with the force of this entity.
LuaEntityLuaEntitytrueThe currently selected entity. Assigning an entity will select it if is selectable, otherwise the selection is cleared.
LuaEntity | LuaItemStack | LuaEquipment | LuaEquipmentGrid | LuaPlayer | LuaGuiElement | LuaInventory | LuaLogisticNetwork | LuaItemStack | defines.gui_typeLuaEntity | LuaItemStack | LuaEquipment | LuaEquipmentGrid | LuaPlayer | LuaGuiElement | LuaInventory | LuaLogisticNetwork | LuaItemStack | defines.gui_typetrueThe GUI the player currently has open.
This is the GUI that will asked to close (by firing the on_gui_closed event) when the Esc or E keys are pressed. If this attribute is non-nil, then writing nil or a new GUI to it will ask the existing GUI to close.
Write supports any of the types. Read will return the entity, equipment, equipment-grid, player, element, inventory, item or nil.
uint32unknownfalseSize of the crafting queue.
doubledoublefalseThe crafting queue progress in the range [0-1]. 0 when no recipe is being crafted.
{ direction: defines.direction, walking: boolean }{ direction: defines.direction, walking: boolean }falseCurrent walking state of the player, or the spider-vehicle the character is driving.
RidingStateRidingStatefalseCurrent riding state of this car, or of the car this player is riding in.
{ mining: boolean, position?: MapPosition }{ mining: boolean, position?: MapPosition }falseCurrent mining state.
When the player isn't mining tiles the player will mine whatever entity is currently selected. See LuaControl::selected and LuaControl::update_selected_entity.
{ position: MapPosition, state: defines.shooting }{ position: MapPosition, state: defines.shooting }falseCurrent shooting state.
booleanbooleanfalseCurrent item-picking state.
{ position: MapPosition, repairing: boolean }{ position: MapPosition, repairing: boolean }falseCurrent repair state.
LuaItemStackunknowntrueThe player's cursor stack. nil if the player controller is a spectator.
ItemIDAndQualityIDPairItemWithQualityIDtrueThe ghost prototype in the player's cursor.
Items in the cursor stack will take priority over the cursor ghost.
LuaRecordunknowntrueThe blueprint record in the player's cursor.
booleanbooleanfalsetrue if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.
Array<CraftingQueueItem>unknownfalseThe current crafting queue items.
Array<LuaEntity>unknownfalseThe current combat robots following the character.
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
booleanbooleanfalseWhen true hand crafting is free and instant.
doubledoublefalseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
doubledoublefalseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Array<string>Array<string>falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
doubledoublefalseModifies the running speed of this character by the given value as a percentage. Setting the running modifier to 0.5 makes the character run 50% faster. The minimum value of -1 reduces the movement speed by 100%, resulting in a speed of 0.
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
uint32uint32falseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
floatfloatfalseWhen called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
defines.gui_typeunknowntrueuint32unknownfalseThe build distance of this character or max uint when not a character or player connected to a character.
uint32unknownfalseThe item drop distance of this character or max uint when not a character or player connected to a character.
uint32unknownfalseThe reach distance of this character or max uint when not a character or player connected to a character.
doubleunknownfalseThe item pickup distance of this character or max double when not a character or player connected to a character.
doubleunknownfalseThe loot pickup distance of this character or max double when not a character or player connected to a character.
doubleunknownfalseThe resource reach distance of this character or max double when not a character or player connected to a character.
booleanunknownfalseWhether this character entity is in combat.
doubleunknownfalseThe current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
doubleunknownfalseThe current mining progress between 0 and 1 of this character, or 0 if they aren't mining.
LuaControl.get_inventory(inventory: defines.inventory) -> LuaInventory?
player.get_inventory(inventory)
takes_table: falsetable_optional: falseGet an inventory belonging to this entity. This can be either the "main" inventory or some auxiliary one, like the module slots or logistic trash slots.
A given defines.inventory is only meaningful for the corresponding LuaObject type. EG: get_inventory(defines.inventory.character_main) is only meaningful if 'this' is a player character. You may get a value back but if the type of 'this' isn't the type referred to by the defines.inventory it's almost guaranteed to not be the inventory asked for.
inventory: defines.inventoryLuaInventory? — The inventory or nil if none with the given index was found.LuaControl.get_inventory_name(inventory: defines.inventory) -> string?
player.get_inventory_name(inventory)
takes_table: falsetable_optional: falseGet name of inventory. Names match keys of defines.inventory.
inventory: defines.inventorystring?LuaControl.get_max_inventory_index() -> defines.inventory
player.get_max_inventory_index()
takes_table: falsetable_optional: falseThe highest index of all inventories this entity can use. Allows iteration over all of them if desired.
defines.inventoryLuaControl.get_main_inventory() -> LuaInventory?
player.get_main_inventory()
takes_table: falsetable_optional: falseGets the main inventory for this character or player if this is a character or player.
LuaInventory? — The inventory or nil if this entity is not a character or player.LuaControl.can_insert(items: ItemStackIdentification) -> boolean
player.can_insert(items)
takes_table: falsetable_optional: falseCan at least some items be inserted?
items: ItemStackIdentification — Items that would be inserted.boolean — true if at least a part of the given items could be inserted into this inventory.LuaControl.insert(items: ItemStackIdentification) -> uint32
player.insert(items)
takes_table: falsetable_optional: falseInsert items into this entity. This works the same way as inserters or shift-clicking: the "best" inventory is chosen automatically.
items: ItemStackIdentification — The items to insert.uint32 — The number of items that were actually inserted.LuaControl.set_gui_arrow{ margin: uint32, type: GuiArrowType }
player.set_gui_arrow{ margin=margin, type=type }
takes_table: truetable_optional: falseCreate an arrow which points at this entity. This is used in the tutorial. For examples, see control.lua in the campaign missions.
margin: uint32type: GuiArrowType — Where to point to. This field determines what other fields are mandatory.LuaControl.clear_gui_arrow()
player.clear_gui_arrow()
takes_table: falsetable_optional: falseRemoves the arrow created by set_gui_arrow.
LuaControl.get_item_count(item?: ItemFilter) -> uint32
player.get_item_count()
takes_table: falsetable_optional: falseGet the number of all or some items in this entity.
item?: ItemFilter — The item to count. If not specified, count all items.uint32LuaControl.has_items_inside() -> boolean
player.has_items_inside()
takes_table: falsetable_optional: falseDoes this entity have any item inside it?
booleanLuaControl.can_reach_entity(entity: LuaEntity) -> boolean
player.can_reach_entity(entity)
takes_table: falsetable_optional: falseCan a given entity be opened or accessed?
entity: LuaEntitybooleanLuaControl.clear_items_inside()
player.clear_items_inside()
takes_table: falsetable_optional: falseRemove all items from this entity.
LuaControl.remove_item(items: ItemStackIdentification) -> uint32
player.remove_item(items)
takes_table: falsetable_optional: falseRemove items from this entity.
items: ItemStackIdentification — The items to remove.uint32 — The number of items that were actually removed.LuaControl.teleport(position: MapPosition, surface?: SurfaceIdentification, raise_teleported?: boolean, snap_to_grid?: boolean, build_check_type?: defines.build_check_type) -> boolean
player.teleport(position, surface)
takes_table: falsetable_optional: falseTeleport the entity to a given position, possibly on another surface.
Some entities may not be teleported. For instance, transport belts won't allow teleportation and this method will always return false when used on any such entity.
You can also pass 1 or 2 numbers as the parameters and they will be used as relative teleport coordinates 'teleport(0, 1)' to move the entity 1 tile positive y. 'teleport(4)' to move the entity 4 tiles to the positive x.
script_raised_teleported will not be raised if teleporting a player with no character.
position: MapPosition — Where to teleport to.surface?: SurfaceIdentification — Surface to teleport to. If not given, will teleport to the entity's current surface. Only players, cars, and spidertrons can be teleported cross-surface.raise_teleported?: boolean — If true, defines.events.script_raised_teleported will be fired on successful entity teleportation.snap_to_grid?: boolean — If false the exact position given is used to instead of snapping to the normal entity grid. This only applies if the entity normally snaps to the grid.build_check_type?: defines.build_check_type — The build check type done when teleporting to the destination. Defaults to script. This is ignored when teleporting between surfaces.boolean — true if the entity was successfully teleported.LuaControl.update_selected_entity(position: MapPosition)
player.update_selected_entity(position)
takes_table: falsetable_optional: falseSelect an entity, as if by hovering the mouse above it.
position: MapPosition — Position of the entity to select.LuaControl.clear_selected_entity()
player.clear_selected_entity()
takes_table: falsetable_optional: falseUnselect any selected entity.
LuaControl.disable_flashlight()
player.disable_flashlight()
takes_table: falsetable_optional: falseDisable the flashlight.
Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.
LuaControl.enable_flashlight()
player.enable_flashlight()
takes_table: falsetable_optional: falseEnable the flashlight.
Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.
LuaControl.is_flashlight_enabled() -> boolean
player.is_flashlight_enabled()
takes_table: falsetable_optional: falseIs the flashlight enabled for the current controller. Only supported by defines.controllers.character and defines.controllers.remote.
booleanLuaControl.get_craftable_count(recipe: RecipeID) -> uint32
player.get_craftable_count(recipe)
takes_table: falsetable_optional: falseGets the count of the given recipe that can be crafted.
recipe: RecipeID — The recipe.uint32 — The count that can be crafted.LuaControl.begin_crafting{ count: uint32, recipe: RecipeID, silent?: boolean } -> uint32
player.begin_crafting{ count=count, recipe=recipe }
takes_table: truetable_optional: falseBegins crafting the given count of the given recipe.
count: uint32 — The count to craft.recipe: RecipeID — The recipe to craft.silent?: boolean — If false and the recipe can't be crafted the requested number of times printing the failure is skipped.uint32 — The count that was actually started crafting.LuaControl.cancel_crafting{ index: uint32, count: uint32 }
player.cancel_crafting{ index=index, count=count }
takes_table: truetable_optional: falseCancels the given amount of crafts at the given crafting queue position. If this causes any later crafts that depend on the cancelled one to have insufficient ingredients, those crafts will also be cancelled.
index: uint32 — The crafting queue index.count: uint32 — The count to cancel crafting.LuaControl.mine_entity(entity: LuaEntity, force?: boolean) -> boolean
player.mine_entity(entity, true)
takes_table: falsetable_optional: falseMines the given entity as if this player (or character) mined it.
entity: LuaEntity — The entity to mineforce?: boolean — Forces mining the entity even if the items can't fit in the player.boolean — Whether the mining succeeded.LuaControl.mine_tile(tile: LuaTile) -> boolean
player.mine_tile(tile)
takes_table: falsetable_optional: falseMines the given tile as if this player (or character) mined it.
tile: LuaTile — The tile to mine.boolean — Whether the mining succeeded.LuaControl.is_player() -> boolean
player.is_player()
takes_table: falsetable_optional: falseWhen true control adapter is a LuaPlayer object, false for entities including characters with players.
booleanLuaControl.open_technology_gui(technology?: TechnologyID)
player.open_technology_gui()
takes_table: falsetable_optional: falseOpen the technology GUI and select a given technology.
technology?: TechnologyID — The technology to select after opening the GUI.LuaControl.open_factoriopedia_gui(prototype?: FactoriopediaID)
player.open_factoriopedia_gui()
takes_table: falsetable_optional: falseOpen the Factoriopedia GUI and select a given entry, if any valid ID is given.
prototype?: FactoriopediaIDLuaControl.close_factoriopedia_gui()
player.close_factoriopedia_gui()
takes_table: falsetable_optional: falseCloses the Factoriopedia GUI if it's open.
LuaControl.is_cursor_blueprint() -> boolean
player.is_cursor_blueprint()
takes_table: falsetable_optional: falseReturns whether the player is holding a blueprint. This takes both blueprint items as well as blueprint records from the blueprint library into account.
Note that both this method refers to the currently selected blueprint, which means that a blueprint book with a selected blueprint will return the information as well.
booleanLuaControl.is_cursor_empty() -> boolean
player.is_cursor_empty()
takes_table: falsetable_optional: falseReturns whether the player is holding something in the cursor. Takes into account items from the blueprint library, as well as items and ghost cursor.
booleanLuaControl.get_requester_point() -> LuaLogisticPoint?
player.get_requester_point()
takes_table: falsetable_optional: falseGets the requester logistic point for this entity if it has one.
LuaLogisticPoint?LuaControl.set_driving(driving: boolean, force?: boolean)
player.set_driving(true, true)
takes_table: falsetable_optional: falseSets if this character or player is driving. Returns if the player or character is still driving.
driving: boolean — True for enter-vehicle, false for leave.force?: boolean — If true, the player will be ejected and left at the position of the car if normal "leave" is not possible.LuaControl.can_place_entity{ name: EntityID, position: MapPosition, direction?: defines.direction } -> boolean
player.can_place_entity{ name="name", position=position }
takes_table: truetable_optional: falseChecks if this character or player can build the given entity at the given location on the surface the character or player is on.
name: EntityID — Name of the entity that would be built.position: MapPosition — Where the entity would be placed.direction?: defines.direction — Direction the entity would be facing. Defaults to north.boolean