[2.0.73] LuaUndoRedoStack empty items cannot have actions added to them

Post your bugs and problems so we can fix them.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 451
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

[2.0.73] LuaUndoRedoStack empty items cannot have actions added to them

Post by protocol_1903 »

As in title, if an item is empty (get_undo_item() returns {}) any action that would normally be added to that item would be ignored and not added to any item.

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)))
The associated output:

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
{}
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
Post Reply

Return to “Bug Reports”