I've been using the following commands to test:
Code: Select all
local player = game.get_player(1)
local surface = game.get_surface(1)
surface.create_entity{name = "pipe", position = {0, 0}, player = 1} -- create new undo item
log("initial:")
log(serpent.block(player.undo_redo_stack.get_undo_item(1)))
surface.create_entity{name = "pipe", position = {1, 0}, player = 1, undo_index = 1} -- attempt add to previous index
log("first addition")
log(serpent.block(player.undo_redo_stack.get_undo_item(1)))
player.undo_redo_stack.remove_undo_action(1, 2) -- remove items
player.undo_redo_stack.remove_undo_action(1, 1)
log("cleared")
log(serpent.block(player.undo_redo_stack.get_undo_item(1)))
surface.create_entity{name = "pipe", position = {0, 1}, player = 1, undo_index = 1} -- attempt add to previous index
log("second addition")
log(serpent.block(player.undo_redo_stack.get_undo_item(1)))
Code: Select all
initial:
{
{
surface_index = 1,
target = {
entity_number = 0,
name = "pipe",
position = {
x = 0.5,
y = 0.5
}
},
type = "built-entity"
}
}
first addition
{
{
surface_index = 1,
target = {
entity_number = 0,
name = "pipe",
position = {
x = 0.5,
y = 0.5
}
},
type = "built-entity"
},
{
surface_index = 1,
target = {
entity_number = 0,
name = "pipe",
position = {
x = 1.5,
y = 0.5
}
},
type = "built-entity"
}
}
cleared
{}
second addition
{}
