Automation and Undo

I’ve noticed some very undesirable results during testing when I use UNDO to reverse automation. For instance, I’ve created a bunch of buttons that allow you to purchase units. Payment is automatic and the unit is pulled from a hidden deck to a location for you to freely drag-n-drop onto the map. Everything is working and I’ve vetted the reliability during “normal” play. The only time problems appear is with repeated use of the UNDO button. After testing a dozen or so purchases, I’ll click the UNDO button, say 20 times in rapid succession to undo all the purchases, and then test a different sequence of purchases. When I do that, sometimes currency or units disappear - never to return. The behavior is erratic and not consistent and seems more likely to occur when I click UNDO multiple times. I realize people are unlikely to click undo 20 times in rapid succession during a game, but all it takes is one unit disappearing for players to get frustrated. Have others witnessed this behavior? Any best practices in flowcharting your automation to avoid behavior like that?

PS It’s possible the units don’t actually disappear. The deck is hidden and I haven’t relocated it so I can examine it after a glitch occurs. But in the least, the count showing how many units in that deck breaks and you can no longer purchase the unit. Whether it is physically back in the deck is TBD, but it becomes impossible to repurchase after the undo glitch if you repeat the same exact steps.

There’s at least one major bug filed about UNDO– … i?id=12554

And a very current thread with discussion of several other reproducible UNDO problems:

If you end up able to make a “minimum demonstration module” – a stripped down module that reliably reproduces the problem – then that would probably end up being useful.


I suspect you are seeing an accumulation of the individual Undo cases we are already investigating. It will be next to impossible to debug the ‘20 undo’ case, but if we can nail each individual case, hopefully that will flow through to your situation. We already have a Deck related issue. Do you also use ‘Apply after Move’?

I suggest you add an inventory window to your mod. Have each piece dump every bit of info they know, like where they are, and if it’s important, a command to send them back to known space. I had a different problem where units disappeared, and they were all hiding in a supposedly nonexistent null map. Also, the info you fetch may provide clues for the fixers.