[2.0.5] remove_undo_item() indexing is backwards

This subforum contains all the issues which we already resolved.
robot256
Smart Inserter
Smart Inserter
Posts: 1248
Joined: Sun Mar 17, 2019 1:52 am
Contact:

[2.0.5] remove_undo_item() indexing is backwards

Post by robot256 »

This is a followup to my F10 submission about remove_undo_item() not doing anything. It actually was doing something, just not what the documentation said.

The documentation says that for LuaUndoRedoStack::remove_undo_item(index), "The index of the undo item to remove, ordered from most recent to oldest."

However, testing shows that higher indexes remove more recent items and the index does not match the behavior of get_undo_item().

Reproduction:
  1. In a new save, place a steel chest and then a wooden chest.
  2. Hover over the undo button and see the wooden chest highlighted.
  3. Run "/c game.print(serpent.block(game.player.undo_redo_stack.get_undo_item(1)))" and see that information on the wooden chest is printed, as expected because it is the most recent item.
  4. Run "/c game.player.undo_redo_stack.remove_undo_item(2)", which in theory should remove the older item from the stack, the steel chest.
  5. Hover over the undo button and see the steel chest highlighted because the more recent wooden chest was removed from the stack instead.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4049
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.5] remove_undo_item() indexing is backwards

Post by boskid »

Thanks for the report. You are right, the remove_undo_item(and remove_redo_item since they share an implementation) are indexing items incorrectly. Issue is now fixed for 2.0.6
protocol_1903
Filter Inserter
Filter Inserter
Posts: 281
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: [2.0.5] remove_undo_item() indexing is backwards

Post by protocol_1903 »

Has this been fixed? It doesn't look like remove_undo_item() works at all in 2.0.34

On that note, it appears that remove_undo_action works properly, (the action disappears) but it reappears if it was the only action on the item, i.e. removing all actions from an undo_item does not delete the item.

EDIT: Nevermind, it was my implementation that was weird.
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
Post Reply

Return to “Resolved Problems and Bugs”