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

# Factorio Runtime Docs Version 2.0.77

# LuaEquipmentGrid - Runtime Docs

## Class LuaEquipmentGrid

An equipment grid is for example the inside of a power armor.

## Members

take{position?=…, equipment?=…, by_player?=…} | → ItemWithQualityCount? | Remove an equipment from the grid.
Remove an equipment from the grid.
take_all(by_player?) | → array[ItemWithQualityCount] | Remove all equipment from the grid.
Remove all equipment from the grid.
clear(by_player?) |  | Clear all equipment from the grid, removing it without actually returning it.
Clear all equipment from the grid, removing it without actually returning it.
put{name=…, quality?=…, position?=…, by_player?=…, ghost?=…} | → LuaEquipment? | Insert an equipment into the grid.
Insert an equipment into the grid.
can_move{equipment=…, position=…} | → boolean | Check whether moving an equipment would succeed.
Check whether moving an equipment would succeed.
move{equipment=…, position=…} | → boolean | Move an equipment within this grid.
Move an equipment within this grid.
get(position) | → LuaEquipment? | Find equipment in the Equipment Grid colliding with this position.
Find equipment in the Equipment Grid colliding with this position.
get_contents() | → array[EquipmentWithQualityCounts] | Get counts of all equipment in this grid.
Get counts of all equipment in this grid.
get_generator_energy(quality?) | → double | Total energy per tick generated by the equipment inside this grid.
Total energy per tick generated by the equipment inside this grid.
find(equipment, search_ghosts?) | → LuaEquipment? | Find equipment by name.
Find equipment by name.
count(equipment?) | → uint32 | Get the number of all or some equipment in this grid.
Get the number of all or some equipment in this grid.
revive(equipment) | → LuaEquipment | Revives the given equipment ghost if possible.
Revives the given equipment ghost if possible.
order_removal(equipment) | → boolean | Marks the given equipment for removal. [...]
Marks the given equipment for removal. [...]
cancel_removal(equipment) | → boolean | Cancels removal for the given equipment.
Cancels removal for the given equipment.
prototype | :: R LuaEquipmentGridPrototype |
width | :: R uint32 | Width of the equipment grid.
Width of the equipment grid.
height | :: R uint32 | Height of the equipment grid.
Height of the equipment grid.
equipment | :: R array[LuaEquipment] | All the equipment in this grid.
All the equipment in this grid.
max_solar_energy | :: R double | Maximum energy per tick that can be created by all solar panels in the equipment grid on the current surface. [...]
Maximum energy per tick that can be created by all solar panels in the equipment grid on the current surface. [...]
available_in_batteries | :: R double | The total energy stored in all batteries in the equipment grid.
The total energy stored in all batteries in the equipment grid.
battery_capacity | :: R double | Total energy storage capacity of all batteries in the equipment grid.
Total energy storage capacity of all batteries in the equipment grid.
shield | :: R float | The amount of shield hitpoints this equipment grid currently has across all shield equipment.
The amount of shield hitpoints this equipment grid currently has across all shield equipment.
max_shield | :: R float | The maximum amount of shield hitpoints this equipment grid has across all shield equipment.
The maximum amount of shield hitpoints this equipment grid has across all shield equipment.
inventory_bonus | :: R uint32 | The total amount of inventory bonus this equipment grid gives.
The total amount of inventory bonus this equipment grid gives.
movement_bonus | :: R double | The total amount of movement bonus this equipment grid gives. [...]
The total amount of movement bonus this equipment grid gives. [...]
inhibit_movement_bonus | :: RW boolean | Whether this grid's equipment movement bonus is active.
Whether this grid's equipment movement bonus is active.
unique_id | :: R uint32 | Unique identifier of this equipment grid.
Unique identifier of this equipment grid.
entity_owner | :: R LuaEntity? | The entity that this equipment grid is owned by (in some inventory or item stack.) If the owning entity is a character owned by some player and the player is disconnected this will return `nil`.
The entity that this equipment grid is owned by (in some inventory or item stack.) If the owning entity is a character owned by some player and the player is disconnected this will return `nil`.
player_owner | :: R LuaPlayer? | The player that this equipment grid is owned by (in some inventory or item stack.)
The player that this equipment grid is owned by (in some inventory or item stack.)
itemstack_owner | :: R LuaItemStack? | The item stack that this equipment grid is owned by.
The item stack that this equipment grid is owned by.
valid | :: R boolean | Is this object valid? [...]
Is this object valid? [...]
object_name | :: R string | The class name of this object. [...]
The class name of this object. [...]

## Methods

### take{position?=…, equipment?=…, by_player?=…} → ItemWithQualityCount?

Remove an equipment from the grid.

#### Parameters

Table with the following fields:

position | :: EquipmentPosition? | Take the equipment that contains this position in the grid.
Take the equipment that contains this position in the grid.
equipment | :: LuaEquipment? | Take this exact equipment.
Take this exact equipment.
by_player | :: PlayerIdentification? | If provided the action is done 'as' this player and on_player_removed_equipment is triggered.
If provided the action is done 'as' this player and on_player_removed_equipment is triggered.

#### Return values

→ ItemWithQualityCount? | The removed equipment, or `nil` if no equipment was removed.

### take_all(by_player?) → array[ItemWithQualityCount]

Remove all equipment from the grid.

#### Parameters

by_player | :: PlayerIdentification? | If provided, the action is done 'as' this player and on_player_removed_equipment is triggered.
If provided, the action is done 'as' this player and on_player_removed_equipment is triggered.

#### Return values

→ array[ItemWithQualityCount] | List of the equipment that has been removed.

### clear(by_player?)

Clear all equipment from the grid, removing it without actually returning it.

#### Parameters

by_player | :: PlayerIdentification? | If provided, the action is done 'as' this player and on_player_removed_equipment is triggered.
If provided, the action is done 'as' this player and on_player_removed_equipment is triggered.

### put{name=…, quality?=…, position?=…, by_player?=…, ghost?=…} → LuaEquipment?

Insert an equipment into the grid.

#### Parameters

Table with the following fields:

name | :: EquipmentID | Equipment prototype name
Equipment prototype name
quality | :: QualityID? | The quality, `nil` for any or if not provided `normal` is used.
The quality, `nil` for any or if not provided `normal` is used.
position | :: EquipmentPosition? | Grid position to put the equipment in.
Grid position to put the equipment in.
by_player | :: PlayerIdentification? | If provided the action is done 'as' this player and on_player_placed_equipment is triggered.
If provided the action is done 'as' this player and on_player_placed_equipment is triggered.
ghost | :: boolean? | If true, place the equipment as a ghost.
If true, place the equipment as a ghost.

#### Return values

→ LuaEquipment? | The newly-added equipment, or `nil` if the equipment could not be added.

### can_move{equipment=…, position=…} → boolean

Check whether moving an equipment would succeed.

#### Parameters

Table with the following fields:

equipment | :: LuaEquipment | The equipment to move
The equipment to move
position | :: EquipmentPosition | Where to put it
Where to put it

### move{equipment=…, position=…} → boolean

Move an equipment within this grid.

#### Parameters

Table with the following fields:

equipment | :: LuaEquipment | The equipment to move
The equipment to move
position | :: EquipmentPosition | Where to put it
Where to put it

#### Return values

→ boolean | `true` if the equipment was successfully moved.

### get(position) → LuaEquipment?

Find equipment in the Equipment Grid colliding with this position.

#### Parameters

position | :: EquipmentPosition | The position
The position

#### Return values

→ LuaEquipment? | The found equipment, or `nil` if equipment occupying the given position could not be found.

### get_contents() → array[EquipmentWithQualityCounts]

Get counts of all equipment in this grid.

#### Return values

→ array[EquipmentWithQualityCounts] | List of all equipment in the grid.

### get_generator_energy(quality?) → double

Total energy per tick generated by the equipment inside this grid.

#### Parameters

quality | :: QualityID? | Defaults to `"normal"`.
Defaults to `"normal"`.

### find(equipment, search_ghosts?) → LuaEquipment?

Find equipment by name.

#### Parameters

equipment | :: EquipmentWithQualityID | Prototype of the equipment to find.
Prototype of the equipment to find.
search_ghosts | :: boolean? | If ghosts inner equipment should be searched. Defaults to `false`
If ghosts inner equipment should be searched. Defaults to `false`

#### Return values

→ LuaEquipment? | The first found equipment, or `nil` if equipment could not be found.

### count(equipment?) → uint32

Get the number of all or some equipment in this grid.

#### Parameters

equipment | :: EquipmentWithQualityID? | The equipment to count. If not specified, count all equipment.
The equipment to count. If not specified, count all equipment.

### revive(equipment) → LuaEquipment

Revives the given equipment ghost if possible.

#### Parameters

equipment | :: LuaEquipment | The equipment ghost to revive.
The equipment ghost to revive.

### order_removal(equipment) → boolean

Marks the given equipment for removal. If the given equipment is a ghost it is removed.

#### Parameters

equipment | :: LuaEquipment |

#### Return values

→ boolean | If the equipment was successfully marked for removal (or in the case of a ghost; removed.)

### cancel_removal(equipment) → boolean

Cancels removal for the given equipment.

#### Parameters

equipment | :: LuaEquipment |

#### Return values

→ boolean | If the equipment removal was successfully cancelled.

## Attributes

### prototype :: Read LuaEquipmentGridPrototype

### width :: Read uint32

Width of the equipment grid.

### height :: Read uint32

Height of the equipment grid.

### equipment :: Read array[LuaEquipment]

All the equipment in this grid.

### max_solar_energy :: Read double

Maximum energy per tick that can be created by all solar panels in the equipment grid on the current surface. Actual generated energy varies depending on the daylight levels.

### available_in_batteries :: Read double

The total energy stored in all batteries in the equipment grid.

### battery_capacity :: Read double

Total energy storage capacity of all batteries in the equipment grid.

### shield :: Read float

The amount of shield hitpoints this equipment grid currently has across all shield equipment.

### max_shield :: Read float

The maximum amount of shield hitpoints this equipment grid has across all shield equipment.

### inventory_bonus :: Read uint32

The total amount of inventory bonus this equipment grid gives.

### movement_bonus :: Read double

The total amount of movement bonus this equipment grid gives.

Returns `0` if LuaEquipmentGrid::inhibit_movement_bonus is `true`.

### inhibit_movement_bonus :: Read|Write boolean

Whether this grid's equipment movement bonus is active.

### unique_id :: Read uint32

Unique identifier of this equipment grid.

### entity_owner :: Read LuaEntity?

The entity that this equipment grid is owned by (in some inventory or item stack.)

If the owning entity is a character owned by some player and the player is disconnected this will return `nil`.

### player_owner :: Read LuaPlayer?

The player that this equipment grid is owned by (in some inventory or item stack.)

### itemstack_owner :: Read LuaItemStack?

The item stack that this equipment grid is owned by.

### valid :: Read boolean

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 :: Read string

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.

Class used in

- LuaControl::opened
- LuaEntity::grid
- LuaItemCommon::grid
- LuaItemStack::create_grid()
- RegistrationTarget
- on_equipment_inserted
- on_equipment_removed
- on_player_placed_equipment
- on_player_removed_equipment