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

# Factorio Runtime Docs Version 2.0.77

# LuaTransportLine - Runtime Docs

## Class LuaTransportLine

One line on a transport belt.

## Members

clear() |  | Remove all items from this transport line.
Remove all items from this transport line.
get_item_count(item?) | → uint32 | Count some or all items on this line, similar to how LuaInventory::get_item_count does.
Count some or all items on this line, similar to how LuaInventory::get_item_count does.
remove_item(items) | → uint32 | Remove some items from this line.
Remove some items from this line.
can_insert_at(position) | → boolean | Can an item be inserted at a given position?
Can an item be inserted at a given position?
can_insert_at_back() | → boolean | Can an item be inserted at the back of this line?
Can an item be inserted at the back of this line?
insert_at(position, items, belt_stack_size?) | → boolean | Insert items at a given position.
Insert items at a given position.
insert_at_back(items, belt_stack_size?) | → boolean | Insert items at the back of this line.
Insert items at the back of this line.
force_insert_at(position, items, belt_stack_size?) |  | Force insert item at a given position. [...]
Force insert item at a given position. [...]
get_contents() | → array[ItemWithQualityCount] | Get counts of all items on this line, similar to how LuaInventory::get_contents does.
Get counts of all items on this line, similar to how LuaInventory::get_contents does.
get_detailed_contents() | → array[DetailedItemOnLine] | Get detailed information of items on this line, such as their position.
Get detailed information of items on this line, such as their position.
line_equals(other) | → boolean | Returns whether the associated internal transport line of this line is the same as the others associated internal transport line. [...]
Returns whether the associated internal transport line of this line is the same as the others associated internal transport line. [...]
get_line_item_position(position) | → MapPosition | Get a map position related to a position on a transport line.
Get a map position related to a position on a transport line.
owner | :: R LuaEntity | The entity this transport line belongs to.
The entity this transport line belongs to.
output_lines | :: R array[LuaTransportLine] | The transport lines that this transport line outputs items to or an empty table if none.
The transport lines that this transport line outputs items to or an empty table if none.
input_lines | :: R array[LuaTransportLine] | The transport lines that this transport line is fed by or an empty table if none.
The transport lines that this transport line is fed by or an empty table if none.
line_length | :: R float | Length of the transport line. [...]
Length of the transport line. [...]
total_segment_length | :: R double | Total length of segment which consists of this line, all lines in front and lines in the back directly connected.
Total length of segment which consists of this line, all lines in front and lines in the back directly connected.
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. [...]
[] (index) | :: R LuaItemStack | The indexing operator.
The indexing operator.
# (length) | :: R uint32 | Get the number of items on this transport line.
Get the number of items on this transport line.

## Methods

### clear()

Remove all items from this transport line.

### get_item_count(item?) → uint32

Count some or all items on this line, similar to how LuaInventory::get_item_count does.

#### Parameters

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

### remove_item(items) → uint32

Remove some items from this line.

#### Parameters

items | :: ItemStackIdentification | Items to remove.
Items to remove.

#### Return values

→ uint32 | Number of items actually removed.

### can_insert_at(position) → boolean

Can an item be inserted at a given position?

#### Parameters

position | :: float | Where to insert an item.
Where to insert an item.

### can_insert_at_back() → boolean

Can an item be inserted at the back of this line?

### insert_at(position, items, belt_stack_size?) → boolean

Insert items at a given position.

#### Parameters

position | :: float | Where on the line to insert the items.
Where on the line to insert the items.
items | :: ItemStackIdentification | Items to insert.
Items to insert.
belt_stack_size | :: uint8? | Maximum size of stack created on belt
Maximum size of stack created on belt

#### Return values

→ boolean | Were the items inserted successfully?

### insert_at_back(items, belt_stack_size?) → boolean

Insert items at the back of this line.

#### Parameters

items | :: ItemStackIdentification |
belt_stack_size | :: uint8? | Maximum size of stack created on belt
Maximum size of stack created on belt

#### Return values

→ boolean | Were the items inserted successfully?

### force_insert_at(position, items, belt_stack_size?)

Force insert item at a given position. Inserts item onto a transport line. If a position is out of range, it is clamped to a closest valid position on the transport line. Item will be inserted regardless of other items nearby, possibly forcing items to become squashed.

#### Parameters

position | :: float | Where on the line to insert the items.
Where on the line to insert the items.
items | :: ItemStackIdentification | Items to insert.
Items to insert.
belt_stack_size | :: uint8? | Maximum size of stack created on belt
Maximum size of stack created on belt

### get_contents() → array[ItemWithQualityCount]

Get counts of all items on this line, similar to how LuaInventory::get_contents does.

#### Return values

→ array[ItemWithQualityCount] | List of all items on this line.

### get_detailed_contents() → array[DetailedItemOnLine]

Get detailed information of items on this line, such as their position.

### line_equals(other) → boolean

Returns whether the associated internal transport line of this line is the same as the others associated internal transport line.

This can return true even when the LuaTransportLine::owners are different (so `this == other` is false), because the internal transport lines can span multiple tiles.

#### Parameters

other | :: LuaTransportLine |

### get_line_item_position(position) → MapPosition

Get a map position related to a position on a transport line.

#### Parameters

position | :: float | Linear position along the transport line. Clamped to the transport line range.
Linear position along the transport line. Clamped to the transport line range.

## Attributes

### owner :: Read LuaEntity

The entity this transport line belongs to.

### output_lines :: Read array[LuaTransportLine]

The transport lines that this transport line outputs items to or an empty table if none.

### input_lines :: Read array[LuaTransportLine]

The transport lines that this transport line is fed by or an empty table if none.

### line_length :: Read float

Length of the transport line. Items can be inserted at line position from 0 up to returned value

### total_segment_length :: Read double

Total length of segment which consists of this line, all lines in front and lines in the back directly connected.

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

## Operators

### [] (index)

The indexing operator.

### # (length)

Get the number of items on this transport line.

Class used in

- LuaEntity::get_transport_line()
- LuaTransportLine::line_equals()
- LuaTransportLine::output_lines
- LuaTransportLine::input_lines