The Reproduction and Bug
1) Listen to an on_built_entity event with the following in a control.lua:Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local player_index = event.player_index
game.print("Before: " .. tostring(game.players[player_index].undo_redo_stack.get_undo_item_count()))
event.entity.rotate{by_player=player_index}
game.print("After: " .. tostring(game.players[player_index].undo_redo_stack.get_undo_item_count()))
end)
/c game.print("Current undo stack size: " .. tostring(game.players[1].undo_redo_stack.get_undo_item_count()))
Look! A super handy control.lua file for testing! Better download it before it has a chance to run away:
With this code in (assuming you start with nothing in the undo stack):
Case 1:
-Place an inserter via cursor. It gets rotated when you place it.
-Code will print: Before: 0, After: 1. End with an undo stack size of 2.
-Undo stack now has the placement of the inserter on top, and the rotation on the bottom.
-Press undo once => Inserter destruction
-Press undo again => the command fizzles and does nothing
Case 2:
-Place a blueprint that is just an inserter. It gets rotated when you place it.
-Code will print: Before: 1, After: 2. End with an undo stack size of 2.
-Undo stack now has the rotation on the top, and the entity placement on the bottom.
-Press undo once => Inserter gets un-rotated
-Press undo again => Inserter destruction