Factorio.com|Forums|Wiki|Mod Portal|API Docs Prototype|Runtime|Auxiliary

# Factorio Runtime Docs Version 2.0.7

## Class LuaUndoRedoStack new

The undo queue for a player. The term `item_index` refers to the index of an undo item in the queue, while `action_index` refers to the index of one of the individual actions that make up an undo item.

## Members

get_undo_item(index) | → array[UndoRedoAction] | Gets an undo item from the undo stack.
Gets an undo item from the undo stack.
get_undo_item_count() | → uint | The number undo items in the undo stack.
The number undo items in the undo stack.
remove_undo_item(index) |  | Removes an undo item from the undo stack.
Removes an undo item from the undo stack.
remove_undo_action(item_index, action_index) |  | Removes an undo action from the specified undo item on the undo stack.
Removes an undo action from the specified undo item on the undo stack.
get_redo_item(index) | → array[UndoRedoAction] | Gets an undo item from the redo stack.
Gets an undo item from the redo stack.
get_redo_item_count() | → uint | The number of undo items in the redo stack.
The number of undo items in the redo stack.
remove_redo_item(index) |  | Removes an undo item from the redo stack.
Removes an undo item from the redo stack.
remove_redo_action(item_index, action_index) |  | Removes an undo action from the specified undo item on the redo stack.
Removes an undo action from the specified undo item on the redo stack.
get_undo_tags(item_index, action_index) | → Tags | Gets all tags for the given undo action.
Gets all tags for the given undo action.
get_undo_tag(item_index, action_index, tag_name) | → AnyBasic | Gets the tag with the given name from a specific undo item action, or `nil` if it doesn't exist.
Gets the tag with the given name from a specific undo item action, or `nil` if it doesn't exist.
set_undo_tag(item_index, action_index, tag_name, tag) |  | Sets a new tag with the given name and value on the specified undo item action.
Sets a new tag with the given name and value on the specified undo item action.
remove_undo_tag(item_index, action_index, tag) | → boolean | Removes a tag with the given name from the specified undo item.
Removes a tag with the given name from the specified undo item.
get_redo_tags(item_index, action_index) | → Tags | Gets all tags for the given redo action.
Gets all tags for the given redo action.
get_redo_tag(item_index, action_index, tag_name) | → AnyBasic | Gets the tag with the given name from a specific redo item action, or `nil` if it doesn't exist.
Gets the tag with the given name from a specific redo item action, or `nil` if it doesn't exist.
set_redo_tag(item_index, action_index, tag_name, tag) |  | Sets a new tag with the given name and value on the specified redo item action.
Sets a new tag with the given name and value on the specified redo item action.
remove_redo_tag(item_index, action_index, tag) | → boolean | Removes a tag with the given name from the specified redo item.
Removes a tag with the given name from the specified redo item.
player_index | :: R uint | The index of the player to whom this stack belongs to.
The index of the player to whom this stack belongs to.
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

### get_undo_item(index) → array[UndoRedoAction]

Gets an undo item from the undo stack.

#### Parameters

index | :: uint | The index of the undo item to get, ordered from most recent to oldest.
The index of the undo item to get, ordered from most recent to oldest.

### get_undo_item_count() → uint

The number undo items in the undo stack.

### remove_undo_item(index)

Removes an undo item from the undo stack.

#### Parameters

index | :: uint | The index of the undo item to remove, ordered from most recent to oldest.
The index of the undo item to remove, ordered from most recent to oldest.

### remove_undo_action(item_index, action_index)

Removes an undo action from the specified undo item on the undo stack.

#### Parameters

item_index | :: uint | The index of the undo item to change, ordered from most recent to oldest.
The index of the undo item to change, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action to remove.
The index of the undo action to remove.

### get_redo_item(index) → array[UndoRedoAction]

Gets an undo item from the redo stack.

#### Parameters

index | :: uint | The index of the item to get, ordered from most recent to oldest.
The index of the item to get, ordered from most recent to oldest.

### get_redo_item_count() → uint

The number of undo items in the redo stack.

### remove_redo_item(index)

Removes an undo item from the redo stack.

#### Parameters

index | :: uint | The index of the undo item to remove, ordered from most recent to oldest.
The index of the undo item to remove, ordered from most recent to oldest.

### remove_redo_action(item_index, action_index)

Removes an undo action from the specified undo item on the redo stack.

#### Parameters

item_index | :: uint | The index of the undo item to change, ordered from most recent to oldest.
The index of the undo item to change, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action to remove.
The index of the undo action to remove.

### get_undo_tags(item_index, action_index) → Tags

Gets all tags for the given undo action.

#### Parameters

item_index | :: uint | The index of the undo item, ordered from most recent to oldest.
The index of the undo item, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action.
The index of the undo action.

### get_undo_tag(item_index, action_index, tag_name) → AnyBasic

Gets the tag with the given name from a specific undo item action, or `nil` if it doesn't exist.

#### Parameters

item_index | :: uint | The index of the undo item, ordered from most recent to oldest.
The index of the undo item, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action.
The index of the undo action.
tag_name | :: string | The name of the tag to get.
The name of the tag to get.

### set_undo_tag(item_index, action_index, tag_name, tag)

Sets a new tag with the given name and value on the specified undo item action.

#### Parameters

item_index | :: uint | The index of the undo item, ordered from most recent to oldest.
The index of the undo item, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action.
The index of the undo action.
tag_name | :: string | The name of the tag to set.
The name of the tag to set.
tag | :: AnyBasic | The contents of the new tag.
The contents of the new tag.

### remove_undo_tag(item_index, action_index, tag) → boolean

Removes a tag with the given name from the specified undo item.

#### Parameters

item_index | :: uint | The index of the undo item, ordered from most recent to oldest.
The index of the undo item, ordered from most recent to oldest.
action_index | :: uint | The index of the undo action.
The index of the undo action.
tag | :: string | The name of the tag to remove.
The name of the tag to remove.

#### Return values

→ boolean | Whether the tag existed and was successfully removed.

### get_redo_tags(item_index, action_index) → Tags

Gets all tags for the given redo action.

#### Parameters

item_index | :: uint | The index of the redo item, ordered from most recent to oldest.
The index of the redo item, ordered from most recent to oldest.
action_index | :: uint | The index of the redo action.
The index of the redo action.

### get_redo_tag(item_index, action_index, tag_name) → AnyBasic

Gets the tag with the given name from a specific redo item action, or `nil` if it doesn't exist.

#### Parameters

item_index | :: uint | The index of the redo item, ordered from most recent to oldest.
The index of the redo item, ordered from most recent to oldest.
action_index | :: uint | The index of the redo action.
The index of the redo action.
tag_name | :: string | The name of the tag to get.
The name of the tag to get.

### set_redo_tag(item_index, action_index, tag_name, tag)

Sets a new tag with the given name and value on the specified redo item action.

#### Parameters

item_index | :: uint | The index of the redo item, ordered from most recent to oldest.
The index of the redo item, ordered from most recent to oldest.
action_index | :: uint | The index of the redo action.
The index of the redo action.
tag_name | :: string | The name of the tag to set.
The name of the tag to set.
tag | :: AnyBasic | The contents of the new tag.
The contents of the new tag.

### remove_redo_tag(item_index, action_index, tag) → boolean

Removes a tag with the given name from the specified redo item.

#### Parameters

item_index | :: uint | The index of the redo item, ordered from most recent to oldest.
The index of the redo item, ordered from most recent to oldest.
action_index | :: uint | The index of the redo action.
The index of the redo action.
tag | :: string | The name of the tag to remove.
The name of the tag to remove.

#### Return values

→ boolean | Whether the tag existed and was successfully removed.

## Attributes

### player_index :: Read uint

The index of the player to whom this stack belongs to.

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