Factorio.com|Forums|Wiki|Mod Portal|API Docs

# Factorio Runtime Docs Version 2.0.77

# LuaControl - Runtime Docs

## Class LuaControl abstract

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.

Children LuaEntity LuaPlayer

## Members

get_inventory(inventory) | → LuaInventory? | Get an inventory belonging to this entity. [...]
Get an inventory belonging to this entity. [...]
get_inventory_name(inventory) | → string? | Get name of inventory. [...]
Get name of inventory. [...]
get_max_inventory_index() | → defines.inventory | The highest index of all inventories this entity can use. [...]
The highest index of all inventories this entity can use. [...]
get_main_inventory() | → LuaInventory? | Gets the main inventory for this character or player if this is a character or player.
Gets the main inventory for this character or player if this is a character or player.
can_insert(items) | → boolean | Can at least some items be inserted?
Can at least some items be inserted?
insert(items) | → uint32 | Insert items into this entity. [...]
Insert items into this entity. [...]
set_gui_arrow{margin=…, type=…} |  | Create an arrow which points at this entity. [...]
Create an arrow which points at this entity. [...]
clear_gui_arrow() |  | Removes the arrow created by `set_gui_arrow`.
Removes the arrow created by `set_gui_arrow`.
get_item_count(item?) | → uint32 | Get the number of all or some items in this entity.
Get the number of all or some items in this entity.
has_items_inside() | → boolean | Does this entity have any item inside it?
Does this entity have any item inside it?
can_reach_entity(entity) | → boolean | Can a given entity be opened or accessed?
Can a given entity be opened or accessed?
clear_items_inside() |  | Remove all items from this entity.
Remove all items from this entity.
remove_item(items) | → uint32 | Remove items from this entity.
Remove items from this entity.
teleport(position, surface?, raise_teleported?, snap_to_grid?, build_check_type?) | → boolean | Teleport the entity to a given position, possibly on another surface. [...]
Teleport the entity to a given position, possibly on another surface. [...]
update_selected_entity(position) |  | Select an entity, as if by hovering the mouse above it.
Select an entity, as if by hovering the mouse above it.
clear_selected_entity() |  | Unselect any selected entity.
Unselect any selected entity.
disable_flashlight() |  | Disable the flashlight. [...]
Disable the flashlight. [...]
enable_flashlight() |  | Enable the flashlight. [...]
Enable the flashlight. [...]
is_flashlight_enabled() | → boolean | Is the flashlight enabled for the current controller. [...]
Is the flashlight enabled for the current controller. [...]
get_craftable_count(recipe) | → uint32 | Gets the count of the given recipe that can be crafted.
Gets the count of the given recipe that can be crafted.
begin_crafting{count=…, recipe=…, silent?=…} | → uint32 | Begins crafting the given count of the given recipe.
Begins crafting the given count of the given recipe.
cancel_crafting{index=…, count=…} |  | Cancels the given amount of crafts at the given crafting queue position. [...]
Cancels the given amount of crafts at the given crafting queue position. [...]
mine_entity(entity, force?) | → boolean | Mines the given entity as if this player (or character) mined it.
Mines the given entity as if this player (or character) mined it.
mine_tile(tile) | → boolean | Mines the given tile as if this player (or character) mined it.
Mines the given tile as if this player (or character) mined it.
is_player() | → boolean | When `true` control adapter is a LuaPlayer object, `false` for entities including characters with players.
When `true` control adapter is a LuaPlayer object, `false` for entities including characters with players.
open_technology_gui(technology?) |  | Open the technology GUI and select a given technology.
Open the technology GUI and select a given technology.
open_factoriopedia_gui(prototype?) |  | Open the Factoriopedia GUI and select a given entry, if any valid ID is given.
Open the Factoriopedia GUI and select a given entry, if any valid ID is given.
close_factoriopedia_gui() |  | Closes the Factoriopedia GUI if it's open.
Closes the Factoriopedia GUI if it's open.
is_cursor_blueprint() | → boolean | Returns whether the player is holding a blueprint. [...]
Returns whether the player is holding a blueprint. [...]
is_cursor_empty() | → boolean | Returns whether the player is holding something in the cursor. [...]
Returns whether the player is holding something in the cursor. [...]
get_requester_point() | → LuaLogisticPoint? | Gets the requester logistic point for this entity if it has one.
Gets the requester logistic point for this entity if it has one.
set_driving(driving, force?) |  | Sets if this character or player is driving. [...]
Sets if this character or player is driving. [...]
can_place_entity{name=…, position=…, direction?=…} | → boolean | Checks if this character or player can build the given entity at the given location on the surface the character or player is on.
Checks if this character or player can build the given entity at the given location on the surface the character or player is on.
surface | :: R LuaSurface | The surface this entity is currently on.
The surface this entity is currently on.
surface_index | :: R uint32 | Unique index (ID) associated with the surface this entity is currently on.
Unique index (ID) associated with the surface this entity is currently on.
position | :: R MapPosition | The current position of the entity.
The current position of the entity.
render_position | :: R MapPosition | The current render position of the entity.
The current render position of the entity.
is_flying | :: R boolean | If this player or character entity is flying. [...]
If this player or character entity is flying. [...]
flight_height | :: R double | The current flight height for this player or character entity. [...]
The current flight height for this player or character entity. [...]
vehicle | :: R LuaEntity? | The vehicle the player is currently sitting in.
The vehicle the player is currently sitting in.
cargo_pod | :: R LuaEntity? | The cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.
The cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.
hub | :: R LuaEntity? | The space platform hub the player is currently sitting in.
The space platform hub the player is currently sitting in.
force | :: R LuaForce| W ForceID | The force of this entity. [...]
The force of this entity. [...]
force_index | :: R uint32 | Unique index (ID) associated with the force of this entity.
Unique index (ID) associated with the force of this entity.
selected | :: RW LuaEntity? | The currently selected entity. [...]
The currently selected entity. [...]
opened | :: RW LuaEntity or LuaItemStack or LuaEquipment or LuaEquipmentGrid or LuaPlayer or LuaGuiElement or LuaInventory or LuaLogisticNetwork or LuaItemStack or defines.gui_type? | The GUI the player currently has open. [...]
The GUI the player currently has open. [...]
crafting_queue_size | :: R uint32 | Size of the crafting queue.
Size of the crafting queue.
crafting_queue_progress | :: RW double | The crafting queue progress in the range `[0-1]`. [...]
The crafting queue progress in the range `[0-1]`. [...]
walking_state | :: RW table | Current walking state of the player, or the spider-vehicle the character is driving.
Current walking state of the player, or the spider-vehicle the character is driving.
riding_state | :: RW RidingState | Current riding state of this car, or of the car this player is riding in.
Current riding state of this car, or of the car this player is riding in.
mining_state | :: RW table | Current mining state. [...]
Current mining state. [...]
shooting_state | :: RW table | Current shooting state.
Current shooting state.
picking_state | :: RW boolean | Current item-picking state.
Current item-picking state.
repair_state | :: RW table | Current repair state.
Current repair state.
cursor_stack | :: R LuaItemStack? | The player's cursor stack. [...]
The player's cursor stack. [...]
cursor_ghost | :: R ItemIDAndQualityIDPair| W ItemWithQualityID? | The ghost prototype in the player's cursor. [...]
The ghost prototype in the player's cursor. [...]
cursor_record | :: R LuaRecord? | The blueprint record in the player's cursor.
The blueprint record in the player's cursor.
driving | :: RW boolean | `true` if the player is in a vehicle. [...]
`true` if the player is in a vehicle. [...]
crafting_queue | :: R array[CraftingQueueItem]? | The current crafting queue items.
The current crafting queue items.
following_robots | :: R array[LuaEntity] | The current combat robots following the character. [...]
The current combat robots following the character. [...]
cheat_mode | :: RW boolean | When `true` hand crafting is free and instant.
When `true` hand crafting is free and instant.
character_crafting_speed_modifier | :: RW double | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_mining_speed_modifier | :: RW double | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_additional_mining_categories | :: RW array[string] | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_running_speed_modifier | :: RW double | Modifies the running speed of this character by the given value as a percentage. [...]
Modifies the running speed of this character by the given value as a percentage. [...]
character_build_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_item_drop_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_reach_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_resource_reach_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_item_pickup_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_loot_pickup_distance_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_inventory_slots_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_trash_slot_count_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_maximum_following_robot_count_bonus | :: RW uint32 | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
character_health_bonus | :: RW float | When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
opened_gui_type | :: R defines.gui_type? |
build_distance | :: R uint32 | The build distance of this character or max uint when not a character or player connected to a character.
The build distance of this character or max uint when not a character or player connected to a character.
drop_item_distance | :: R uint32 | The item drop distance of this character or max uint when not a character or player connected to a character.
The item drop distance of this character or max uint when not a character or player connected to a character.
reach_distance | :: R uint32 | The reach distance of this character or max uint when not a character or player connected to a character.
The reach distance of this character or max uint when not a character or player connected to a character.
item_pickup_distance | :: R double | The item pickup distance of this character or max double when not a character or player connected to a character.
The item pickup distance of this character or max double when not a character or player connected to a character.
loot_pickup_distance | :: R double | The loot pickup distance of this character or max double when not a character or player connected to a character.
The loot pickup distance of this character or max double when not a character or player connected to a character.
resource_reach_distance | :: R double | The resource reach distance of this character or max double when not a character or player connected to a character.
The resource reach distance of this character or max double when not a character or player connected to a character.
in_combat | :: R boolean | Whether this character entity is in combat.
Whether this character entity is in combat.
character_running_speed | :: R double | The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
character_mining_progress | :: R double | The current mining progress between 0 and 1 of this character, or 0 if they aren't mining.
The current mining progress between 0 and 1 of this character, or 0 if they aren't mining.

## Methods

### get_inventory(inventory) → LuaInventory?

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

#### Parameters

inventory | :: defines.inventory |

#### Return values

→ LuaInventory? | The inventory or `nil` if none with the given index was found.

### get_inventory_name(inventory) → string?

Get name of inventory. Names match keys of defines.inventory.

#### Parameters

inventory | :: defines.inventory |

### get_max_inventory_index() → defines.inventory

The highest index of all inventories this entity can use. Allows iteration over all of them if desired.

#### Example

    for k = 1, entity.get_max_inventory_index() do [...] end

### get_main_inventory() → LuaInventory?

Gets the main inventory for this character or player if this is a character or player.

#### Return values

→ LuaInventory? | The inventory or `nil` if this entity is not a character or player.

### can_insert(items) → boolean

Can at least some items be inserted?

#### Parameters

items | :: ItemStackIdentification | Items that would be inserted.
Items that would be inserted.

#### Return values

→ boolean | `true` if at least a part of the given items could be inserted into this inventory.

### insert(items) → uint32

Insert items into this entity. This works the same way as inserters or shift-clicking: the "best" inventory is chosen automatically.

#### Parameters

items | :: ItemStackIdentification | The items to insert.
The items to insert.

#### Return values

→ uint32 | The number of items that were actually inserted.

### set_gui_arrow{margin=…, type=…}

Create an arrow which points at this entity. This is used in the tutorial. For examples, see `control.lua` in the campaign missions.

#### Parameters

Table with the following fields:

margin | :: uint32 |
type | :: GuiArrowType | Where to point to. This field determines what other fields are mandatory.
Where to point to. This field determines what other fields are mandatory.

Other attributes may be specified depending on `type`:

#### `entity`

entity | :: LuaEntity |

#### `position`

position | :: MapPosition |

#### `crafting_queue`

crafting_queueindex | :: uint32 | Index in the crafting queue to point to.
Index in the crafting queue to point to.

#### `item_stack`

inventory_index | :: defines.inventory | Which inventory the stack is in.
Which inventory the stack is in.
item_stack_index | :: uint32 | Which stack to point to.
Which stack to point to.
source | :: `"player"` or `"target"` or `"player-quickbar"` |

### clear_gui_arrow()

Removes the arrow created by `set_gui_arrow`.

### get_item_count(item?) → uint32

Get the number of all or some items in this entity.

#### Parameters

item | :: ItemFilter? | The item to count. If not specified, count all items.
The item to count. If not specified, count all items.

### has_items_inside() → boolean

Does this entity have any item inside it?

### can_reach_entity(entity) → boolean

Can a given entity be opened or accessed?

#### Parameters

entity | :: LuaEntity |

### clear_items_inside()

Remove all items from this entity.

### remove_item(items) → uint32

Remove items from this entity.

#### Parameters

items | :: ItemStackIdentification | The items to remove.
The items to remove.

#### Return values

→ uint32 | The number of items that were actually removed.

### teleport(position, surface?, raise_teleported?, snap_to_grid?, build_check_type?) → boolean

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

#### Parameters

position | :: MapPosition | Where to teleport to.
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.
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.
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.
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.
The build check type done when teleporting to the destination. Defaults to `script`. This is ignored when teleporting between surfaces.

#### Return values

→ boolean | `true` if the entity was successfully teleported.

#### Raised events

on_player_changed_position? instantly | Raised if the teleported entity is a player character.
script_raised_teleported? instantly | Raised if the `raise_teleported` flag was set and the entity was successfully teleported.

### update_selected_entity(position)

Select an entity, as if by hovering the mouse above it.

#### Parameters

position | :: MapPosition | Position of the entity to select.
Position of the entity to select.

#### Raised events

on_selected_entity_changed? instantly | Raised if there is an entity at the given position to select.

### clear_selected_entity()

Unselect any selected entity.

#### Raised events

on_selected_entity_changed? instantly | Raised if there is a currently selected entity.

### disable_flashlight()

Disable the flashlight.

Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.

### enable_flashlight()

Enable the flashlight.

Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.

### is_flashlight_enabled() → boolean

Is the flashlight enabled for the current controller. Only supported by defines.controllers.character and defines.controllers.remote.

### get_craftable_count(recipe) → uint32

Gets the count of the given recipe that can be crafted.

#### Parameters

recipe | :: RecipeID | The recipe.
The recipe.

#### Return values

→ uint32 | The count that can be crafted.

### begin_crafting{count=…, recipe=…, silent?=…} → uint32

Begins crafting the given count of the given recipe.

#### Parameters

Table with the following fields:

count | :: uint32 | The count to craft.
The count to craft.
recipe | :: RecipeID | The recipe to craft.
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.
If false and the recipe can't be crafted the requested number of times printing the failure is skipped.

#### Return values

→ uint32 | The count that was actually started crafting.

#### Raised events

on_pre_player_crafted_item? instantly | Raised if crafting was able to be started.
on_player_main_inventory_changed? current_tick | Raised if crafting was able to be started.

### cancel_crafting{index=…, count=…}

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

#### Parameters

Table with the following fields:

index | :: uint32 | The crafting queue index.
The crafting queue index.
count | :: uint32 | The count to cancel crafting.
The count to cancel crafting.

#### Raised events

on_player_cancelled_crafting? instantly | Raised if crafting was able to be cancelled.
on_player_main_inventory_changed? current_tick | Raised if crafting was able to be cancelled.

### mine_entity(entity, force?) → boolean

Mines the given entity as if this player (or character) mined it.

#### Parameters

entity | :: LuaEntity | The entity to mine
The entity to mine
force | :: boolean? | Forces mining the entity even if the items can't fit in the player.
Forces mining the entity even if the items can't fit in the player.

#### Return values

→ boolean | Whether the mining succeeded.

#### Raised events

on_pre_player_mined_item? instantly | Raised if mining is possible.
on_player_mined_entity? instantly | Raised if mining is successful.
on_player_mined_item? instantly | Raised if mining is successful.

### mine_tile(tile) → boolean

Mines the given tile as if this player (or character) mined it.

#### Parameters

tile | :: LuaTile | The tile to mine.
The tile to mine.

#### Return values

→ boolean | Whether the mining succeeded.

#### Raised events

on_player_mined_item? instantly | Raised if mining is successful.
on_player_mined_tile? instantly | Raised if mining is successful.

### is_player() → boolean

When `true` control adapter is a LuaPlayer object, `false` for entities including characters with players.

### open_technology_gui(technology?)

Open the technology GUI and select a given technology.

#### Parameters

technology | :: TechnologyID? | The technology to select after opening the GUI.
The technology to select after opening the GUI.

### open_factoriopedia_gui(prototype?)

Open the Factoriopedia GUI and select a given entry, if any valid ID is given.

#### Parameters

prototype | :: FactoriopediaID? |

### close_factoriopedia_gui()

Closes the Factoriopedia GUI if it's open.

### is_cursor_blueprint() → boolean

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

### is_cursor_empty() → boolean

Returns whether the player is holding something in the cursor. Takes into account items from the blueprint library, as well as items and ghost cursor.

### get_requester_point() → LuaLogisticPoint?

Gets the requester logistic point for this entity if it has one.

### set_driving(driving, force?)

Sets if this character or player is driving. Returns if the player or character is still driving.

#### Parameters

driving | :: boolean | True for enter-vehicle, false for leave.
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.
If true, the player will be ejected and left at the position of the car if normal "leave" is not possible.

### can_place_entity{name=…, position=…, direction?=…} → boolean

Checks if this character or player can build the given entity at the given location on the surface the character or player is on.

#### Parameters

Table with the following fields:

name | :: EntityID | Name of the entity that would be built.
Name of the entity that would be built.
position | :: MapPosition | Where the entity would be placed.
Where the entity would be placed.
direction | :: defines.direction? | Direction the entity would be facing. Defaults to `north`.
Direction the entity would be facing. Defaults to `north`.

## Attributes

### surface :: Read LuaSurface

The surface this entity is currently on.

### surface_index :: Read uint32

Unique index (ID) associated with the surface this entity is currently on.

### position :: Read MapPosition

The current position of the entity.

### render_position :: Read MapPosition

The current render position of the entity.

### is_flying :: Read boolean

If this player or character entity is flying.

When called on an entity, only valid if this entity is a character.

### flight_height :: Read double

The current flight height for this player or character entity.

When called on an entity, only valid if this entity is a character.

### vehicle :: Read LuaEntity?

The vehicle the player is currently sitting in.

### cargo_pod :: Read LuaEntity?

The cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.

### hub :: Read LuaEntity?

The space platform hub the player is currently sitting in.

### force :: Read LuaForce| Write ForceID

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

### force_index :: Read uint32

Unique index (ID) associated with the force of this entity.

### selected :: Read|Write LuaEntity?

The currently selected entity. Assigning an entity will select it if is selectable, otherwise the selection is cleared.

#### Raised events

on_selected_entity_changed? instantly | Raised when a selectable entity is written to this attribute.

### opened :: Read|Write LuaEntity or LuaItemStack or LuaEquipment or LuaEquipmentGrid or LuaPlayer or LuaGuiElement or LuaInventory or LuaLogisticNetwork or LuaItemStack or defines.gui_type?

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

#### Raised events

on_gui_opened? instantly | Raised when writing a valid GUI target to this attribute.

### crafting_queue_size :: Read uint32

Size of the crafting queue.

### crafting_queue_progress :: Read|Write double

The crafting queue progress in the range `[0-1]`. `0` when no recipe is being crafted.

### walking_state :: Read|Write table

Current walking state of the player, or the spider-vehicle the character is driving.

#### Table fields

walking | :: boolean | If `false`, the player is currently not walking; otherwise it's going somewhere
If `false`, the player is currently not walking; otherwise it's going somewhere
direction | :: defines.direction | Direction where the player is walking
Direction where the player is walking

#### Example

    -- Make the player go north. Note that a one-shot action like this will only make the player walk for one tick.
    game.player.walking_state = {walking = true, direction = defines.direction.north}

### riding_state :: Read|Write RidingState

Current riding state of this car, or of the car this player is riding in.

### mining_state :: Read|Write table

Current mining state. Will error if written to with a controller_type other than `character`, `god`, or `editor`.

When the player isn't mining tiles the player will mine whatever entity is currently selected. See LuaControl::selected and LuaControl::update_selected_entity.

#### Table fields

mining | :: boolean | Whether the player is mining at all.
Whether the player is mining at all.
position | :: MapPosition? | What location the player is mining. Only relevant if `mining` is `true`.
What location the player is mining. Only relevant if `mining` is `true`.

### shooting_state :: Read|Write table

Current shooting state.

#### Table fields

state | :: defines.shooting | The current state
The current state
position | :: MapPosition | The position being shot at
The position being shot at

### picking_state :: Read|Write boolean

Current item-picking state.

### repair_state :: Read|Write table

Current repair state.

#### Table fields

repairing | :: boolean | The current state
The current state
position | :: MapPosition | The position being repaired
The position being repaired

### cursor_stack :: Read LuaItemStack?

The player's cursor stack. `nil` if the player controller is a spectator.

#### Example

    -- Even though this property is marked as read-only, it returns a LuaItemStack,
    -- meaning it can be manipulated like so:
    player.cursor_stack.clear()

### cursor_ghost :: Read ItemIDAndQualityIDPair| Write ItemWithQualityID?

The ghost prototype in the player's cursor.

Items in the cursor stack will take priority over the cursor ghost.

### cursor_record :: Read LuaRecord?

The blueprint record in the player's cursor.

### driving :: Read|Write boolean

`true` if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.

#### Raised events

on_player_driving_changed_state? instantly | Raised if the driving state successfully changed.

### crafting_queue :: Read array[CraftingQueueItem]?

The current crafting queue items.

### following_robots :: Read array[LuaEntity]

The current combat robots following the character.

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### cheat_mode :: Read|Write boolean

When `true` hand crafting is free and instant.

### character_crafting_speed_modifier :: Read|Write double

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_mining_speed_modifier :: Read|Write double

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_additional_mining_categories :: Read|Write array[string]

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_running_speed_modifier :: Read|Write double

Modifies 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).

### character_build_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_item_drop_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_reach_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_resource_reach_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_item_pickup_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_loot_pickup_distance_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_inventory_slots_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_trash_slot_count_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_maximum_following_robot_count_bonus :: Read|Write uint32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### character_health_bonus :: Read|Write float

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

### opened_gui_type :: Read defines.gui_type?

### build_distance :: Read uint32

The build distance of this character or max uint when not a character or player connected to a character.

### drop_item_distance :: Read uint32

The item drop distance of this character or max uint when not a character or player connected to a character.

### reach_distance :: Read uint32

The reach distance of this character or max uint when not a character or player connected to a character.

### item_pickup_distance :: Read double

The item pickup distance of this character or max double when not a character or player connected to a character.

### loot_pickup_distance :: Read double

The loot pickup distance of this character or max double when not a character or player connected to a character.

### resource_reach_distance :: Read double

The resource reach distance of this character or max double when not a character or player connected to a character.

### in_combat :: Read boolean

Whether this character entity is in combat.

### character_running_speed :: Read double

The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.

### character_mining_progress :: Read double

The current mining progress between 0 and 1 of this character, or 0 if they aren't mining.