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

# Factorio Runtime Docs Version 2.0.77

# LuaSchedule - Runtime Docs

## Class LuaSchedule

The schedule of a particular LuaTrain or LuaSpacePlatform.

## Members

add_wait_condition(record_position, condition_index, type) |  | Adds the given wait condition to the given record.
Adds the given wait condition to the given record.
remove_wait_condition(record_position, condition_index) |  | Removes the given wait condition from the given record.
Removes the given wait condition from the given record.
set_wait_condition_mode(record_position, condition_index, mode) |  | Sets the comparison on the given wait condition.
Sets the comparison on the given wait condition.
change_wait_condition(record_position, condition_index, wait_condition) |  | Changes the wait condition on the given record to the new values.
Changes the wait condition on the given record to the new values.
add_record(data) | → uint32? | Adds the given record to the end of the current schedule or at the given index using the provided data.
Adds the given record to the end of the current schedule or at the given index using the provided data.
remove_record(record_position) |  | Removes the record at the given record position, if the record position is valid.
Removes the record at the given record position, if the record position is valid.
copy_record(source_schedule, source_index, destination_index) |  | Copies the record from the given schedule at the given index into this schedule at the given index.
Copies the record from the given schedule at the given index into this schedule at the given index.
add_interrupt(interrupt) |  | Adds the given interrupt to the schedule if an interrupt with the given name does not already exist.
Adds the given interrupt to the schedule if an interrupt with the given name does not already exist.
remove_interrupt(index) |  | Removes the interrupt at the given index, if the index is valid.
Removes the interrupt at the given index, if the index is valid.
activate_interrupt(index) |  | Activates the interrupt at the given index, if the index is valid.
Activates the interrupt at the given index, if the index is valid.
change_interrupt(index, interrupt) |  | Changes the interrupt at the given index to the provided values. [...]
Changes the interrupt at the given index to the provided values. [...]
rename_interrupt(old_name, new_name) |  |
go_to_station(schedule_index) |  | Sets the train or space platform to go to a destination, including changing the train/space platform to automatic mode.
Sets the train or space platform to go to a destination, including changing the train/space platform to automatic mode.
set_stopped(stopped) |  | Sets whether this train is in manual mode or this space platform is paused.
Sets whether this train is in manual mode or this space platform is paused.
set_allow_unloading(record_position, allow) |  | Sets if unloading is allowed at the given schedule record position. [...]
Sets if unloading is allowed at the given schedule record position. [...]
drag_record(from, to, interrupt_index?) |  |
drag_interrupt(from, to) |  |
drag_wait_condition(record_position, from, to) |  |
get_record(record_position) | → ScheduleRecord? |
get_records(interrupt_index?) | → array[ScheduleRecord]? |
set_records(records, interrupt_index?) |  |
clear_records(interrupt_index?) |  |
get_interrupt(index) | → ScheduleInterrupt? |
get_interrupts() | → array[ScheduleInterrupt] |
set_interrupts(interrupts) |  |
clear_interrupts() |  | Removes all interrupts.
Removes all interrupts.
get_wait_condition(record_position, condition_index) | → WaitCondition? | Gets the wait condition at the given record position if one exists.
Gets the wait condition at the given record position if one exists.
get_wait_conditions(record_position) | → array[WaitCondition]? | Gets the wait conditions at the given record position if they exist.
Gets the wait conditions at the given record position if they exist.
get_wait_condition_count(record_position) | → uint32? | The number of wait conditions in the given schedule record.
The number of wait conditions in the given schedule record.
get_inside_interrupt(interrupt_index) | → boolean | Gets if the given interrupt can be triggered inside other interrupts.
Gets if the given interrupt can be triggered inside other interrupts.
set_inside_interrupt(interrupt_index, value) |  | Sets if the given interrupt can be triggered inside other interrupts.
Sets if the given interrupt can be triggered inside other interrupts.
get_record_count(interrupt_index?) | → uint32? | If the given index is invalid, `nil` is returned.
If the given index is invalid, `nil` is returned.
owner | :: R LuaTrain or LuaSpacePlatform? | The owner of this schedule.
The owner of this schedule.
interrupt_count | :: R uint32 |
current | :: R uint32 | The schedule index of the current destination.
The schedule index of the current destination.
tick_of_last_schedule_change | :: R MapTick |
tick_of_last_activity | :: RW MapTick | The time when the train or space platform was last considered active for the inactivity condition. [...]
The time when the train or space platform was last considered active for the inactivity condition. [...]
ticks_in_station | :: R MapTick | How long this train or space platform has been in the current station.
How long this train or space platform has been in the current station.
group | :: RW string? | The group this schedule is part of, if any.
The group this schedule is part of, if any.
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

### add_wait_condition(record_position, condition_index, type)

Adds the given wait condition to the given record.

#### Parameters

record_position | :: ScheduleRecordPosition |
condition_index | :: uint32 |
type | :: WaitConditionType |

### remove_wait_condition(record_position, condition_index)

Removes the given wait condition from the given record.

#### Parameters

record_position | :: ScheduleRecordPosition |
condition_index | :: uint32 |

### set_wait_condition_mode(record_position, condition_index, mode)

Sets the comparison on the given wait condition.

#### Parameters

record_position | :: ScheduleRecordPosition |
condition_index | :: uint32 |
mode | :: string | `"and"`, or `"or"`
`"and"`, or `"or"`

### change_wait_condition(record_position, condition_index, wait_condition)

Changes the wait condition on the given record to the new values.

#### Parameters

record_position | :: ScheduleRecordPosition |
condition_index | :: uint32 |
wait_condition | :: WaitCondition |

### add_record(data) → uint32?

Adds the given record to the end of the current schedule or at the given index using the provided data.

#### Parameters

data | :: AddRecordData |

#### Return values

→ uint32? | The index the record was added at.

### remove_record(record_position)

Removes the record at the given record position, if the record position is valid.

#### Parameters

record_position | :: ScheduleRecordPosition |

### copy_record(source_schedule, source_index, destination_index)

Copies the record from the given schedule at the given index into this schedule at the given index.

#### Parameters

source_schedule | :: LuaSchedule |
source_index | :: uint32 |
destination_index | :: uint32 |

### add_interrupt(interrupt)

Adds the given interrupt to the schedule if an interrupt with the given name does not already exist.

#### Parameters

interrupt | :: ScheduleInterrupt |

### remove_interrupt(index)

Removes the interrupt at the given index, if the index is valid.

#### Parameters

index | :: uint32 |

### activate_interrupt(index)

Activates the interrupt at the given index, if the index is valid.

#### Parameters

index | :: uint32 |

### change_interrupt(index, interrupt)

Changes the interrupt at the given index to the provided values. Note, the names must match.

#### Parameters

index | :: uint32 |
interrupt | :: ScheduleInterrupt |

### rename_interrupt(old_name, new_name)

#### Parameters

old_name | :: string | The interrupt to rename
The interrupt to rename
new_name | :: string | The new name - if it already exists, does nothing.
The new name - if it already exists, does nothing.

### go_to_station(schedule_index)

Sets the train or space platform to go to a destination, including changing the train/space platform to automatic mode.

#### Parameters

schedule_index | :: uint32 | The schedule index
The schedule index

### set_stopped(stopped)

Sets whether this train is in manual mode or this space platform is paused.

#### Parameters

stopped | :: boolean |

### set_allow_unloading(record_position, allow)

Sets if unloading is allowed at the given schedule record position. Only relevant for space platforms.

#### Parameters

record_position | :: ScheduleRecordPosition |
allow | :: boolean |

### drag_record(from, to, interrupt_index?)

#### Parameters

from | :: uint32 |
to | :: uint32 |
interrupt_index | :: uint32? | The interrupt to operate on, if any.
The interrupt to operate on, if any.

### drag_interrupt(from, to)

#### Parameters

from | :: uint32 |
to | :: uint32 |

### drag_wait_condition(record_position, from, to)

#### Parameters

record_position | :: ScheduleRecordPosition | The record to change.
The record to change.
from | :: uint32 |
to | :: uint32 |

### get_record(record_position) → ScheduleRecord?

#### Parameters

record_position | :: ScheduleRecordPosition |

### get_records(interrupt_index?) → array[ScheduleRecord]?

#### Parameters

interrupt_index | :: uint32? | If provided, gets the records for this interrupt.
If provided, gets the records for this interrupt.

### set_records(records, interrupt_index?)

#### Parameters

records | :: array[ScheduleRecord] |
interrupt_index | :: uint32? | If provided, the records will be set on this interrupt.
If provided, the records will be set on this interrupt.

### clear_records(interrupt_index?)

#### Parameters

interrupt_index | :: uint32? | If provided, clears the records for this interrupt.
If provided, clears the records for this interrupt.

### get_interrupt(index) → ScheduleInterrupt?

#### Parameters

index | :: uint32 |

### get_interrupts() → array[ScheduleInterrupt]

### set_interrupts(interrupts)

#### Parameters

interrupts | :: array[ScheduleInterrupt] |

### clear_interrupts()

Removes all interrupts.

### get_wait_condition(record_position, condition_index) → WaitCondition?

Gets the wait condition at the given record position if one exists.

#### Parameters

record_position | :: ScheduleRecordPosition |
condition_index | :: uint32 |

### get_wait_conditions(record_position) → array[WaitCondition]?

Gets the wait conditions at the given record position if they exist.

#### Parameters

record_position | :: ScheduleRecordPosition |

### get_wait_condition_count(record_position) → uint32?

The number of wait conditions in the given schedule record.

#### Parameters

record_position | :: ScheduleRecordPosition |

### get_inside_interrupt(interrupt_index) → boolean

Gets if the given interrupt can be triggered inside other interrupts.

#### Parameters

interrupt_index | :: uint32 |

### set_inside_interrupt(interrupt_index, value)

Sets if the given interrupt can be triggered inside other interrupts.

#### Parameters

interrupt_index | :: uint32 |
value | :: boolean |

### get_record_count(interrupt_index?) → uint32?

If the given index is invalid, `nil` is returned.

#### Parameters

interrupt_index | :: uint32? | If provided, the record count in this interrupt is read.
If provided, the record count in this interrupt is read.

## Attributes

### owner :: Read LuaTrain or LuaSpacePlatform?

The owner of this schedule.

### interrupt_count :: Read uint32

### current :: Read uint32

The schedule index of the current destination.

### tick_of_last_schedule_change :: Read MapTick

### tick_of_last_activity :: Read|Write MapTick

The time when the train or space platform was last considered active for the inactivity condition.

Note: when writing, value must not be larger than LuaGameScript::tick

### ticks_in_station :: Read MapTick

How long this train or space platform has been in the current station.

### group :: Read|Write string?

The group this schedule is part of, if any.

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

- LuaSchedule::copy_record()
- LuaSpacePlatform::get_schedule()
- LuaTrain::get_schedule()
- RegistrationTarget