MagmaMcFry/Factorissimo2

Crash: Error while running event Factorissimo2::on_marked_for_deconstruction

dominics opened this issue · 1 comments

Version: 2.1.8
Factorio version: 0.15.34

When deconstructing a factory building, crashes with the following error:

Error while running event Factorissimo2::on_marked_for_deconstruction (ID 20) LuaEntity API call when LuaEntity was invalid. stack traceback: Factorissimo2/control.lua:784: in function <Factorissimo2/control.lua:765>

Setup is a few empty 02 size factories inside an otherwise empty 03 factory, when the final inner factory is marked for deconstruction (always happens on the last one to be marked, regardless of the order in which the inner factories are marked).

Trying to manually pick up the final inner factory (that would otherwise crash) gives: "Could not pick up factory, too many factories picked up at once". (That made me think I had hit a Factorissimo-1 style hard limit to the number of inactive factories floating around - but destroying a bunch didn't help.).

Happy to share a save game (but it is 27MB zipped, and I'm using 27 mods 😑). Deconstructing the outer factory worked nicely (so not save-breaking or anything 😌).

Ah, I see. It seems that you have picked up (or marked for deconstruction) a huge amount of factories at once. There's a hidden built-in limitation of Factorissimo2 where you can pick up (or mark for deconstruction) only up to 90 factory buildings of each type at once. The crash is because there's a bug in the error handler. In the meantime, you'll have to place some of your Mk2 factories down before you pick more up.

Factories that were destroyed while not in active building form will still count towards that limit, so be careful! The command /give-lost-factory-buildings will give you an item linked to each factory building that counts as picked up at the moment (including those that you destroyed in item form). Of course this will mean that you'll have multiple items linked to the same interior, but the duplicates will destroy themselves upon placement.

Once you've got all your factory buildings back, to deal with the large amount of spare factory buildings, just place them somewhere they won't take up space, maybe inside each other. If you like, you can destroy them while they're placed in a valid location, that way they won't take up any energy-sharing CPU time and they won't count as picked up.

If you want to know why there's this hard pickup limit, it's because Factorissimo2 stores factory data in the type of the item, as opposed to its health in Factorissimo1. Every factory building secretly has 90 hidden item types all looking identical, and in regular play at most 1 item of each of these types exists. Since you can't dynamically create item types while playing, there needs to be a hard limit on that.