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

This subforum contains all the issues which we already resolved.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 512
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 fluid networks and subtick events in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903

Buy me a coffee
Rseding91
Factorio Staff
Factorio Staff
Posts: 16885
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Thanks for the report. This is now fixed for 2.1.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”