Reverse Factory

by Kryzeth

Reverse Factory machine will recycle (uncraft) nearly any item placed inside. Supports the recycling of most, if not all, modded items. Fully featured integration with Bobs Mods, Industrial Revolution, and Fantario (independently, not simultaneously)

Content
14 days ago
0.13 - 1.1
56.1K
Manufacturing

b [Fixed] Error with NewGame+

4 years ago
(updated 4 years ago)

Wanted to create new game from an old savegame then the game crashed right before i could go on. Before it worked without any problems.

Error while running event reverse-factory::on_tick (ID 0)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
reverse-factory/control.lua:8: in function 'checkinvs'
reverse-factory/control.lua:81: in function <reverse-factory/control.lua:77>
stack traceback:
[C]: in function 'index'
__reverse-factory
/control.lua:8: in function 'checkinvs'
reverse-factory/control.lua:81: in function <reverse-factory/control.lua:77>

4 years ago
(updated 4 years ago)

Hm, when you say NewGame+, do you mean this mod? I'm guessing that when it moves you into a new game, my mod still expects there to be a bunch of recyclers in the world, which are no longer there, and are invalid data, so it errors out.

Try disabling the Automatic Ingredient Push Setting before moving into new game plus, then save once you've loaded up, re-enable the setting and continue playing. Or you can just keep the setting disabled, if it causes any further crashes.

Automatic Ingredient Push only affects powered reverse factories, when you put in something like half a yellow belt (which usually crafts in pairs), which is not enough to recycle the recipe, and so it pushes it into the output slot, instead of waiting for a second yellow belt. You can safely disable the setting to prevent this issue.

I'll look into this compatibility issue and see if I can detect when player is moving into new game plus, and clear the list of recyclers to prevent this error. But it's avoidable for now, and doesn't cause a complete game crash, so not a top priority atm.

4 years ago
(updated 4 years ago)

Updated your mod and deactivated Automatic Ingredient Push Setting but i still get the error message. So i deactivated your mod, made a new NewGame+ savegame and reactivated your mod.

Yes its this mod. I had used this mod with your mod together and it worked multiple times. But since there are a few updates from your mod and factorio itself.

4 years ago

Kryzeth: I'll channel Klonan and say: always check .valid. Lots of things can make a Factorio lua object go invalid, and NGP just happens to be the one that you got a bug report for. It'll break the same way with Creative Mode instant-destroy I suspect, and potentially lots of other things. :)

4 years ago

Hm... that's weird, especially if it worked before and randomly stopped working. At least disabling and re-enabling still works, though it probably means you can't carry over any reverse factories (and will have to re-research the tech, most likely).

But really, if you disable the setting, nothing should be running in control.lua; there shouldn't be any error. Did you make sure to disable the setting while you were in the save game?

Factorio is really weird in that it has the map settings appear on the main menu, but they only affect new games. You have to actually load up the save file, change the setting (while still in the save file), save the save file, then reload the save file, and then the setting change will actually stick. At least that's what I remember having to do

4 years ago
(updated 4 years ago)

@slippycheeze Thanks for the suggestion about .valid; I never even knew that existed, but it's super helpful. Was able to make this work for v6.1.12 without needing to disable any settings.

As a bonus, any time that a recycler becomes invalid, it will be immediately removed from the list and not get checked any further, in case any other mods mess with them outside of vanilla. Super helpful future proofing.

4 years ago

NP. the main thing to remember is that any API call can run arbitrary code in other mods, and other mods can invalidate any API object (with a .valid) at any time they run their code, so checking valid is only, uh, valid, for as long as you are not letting anything else run.

...but checking .valid is super, super cheap, so you can do it umpty-million times in your code and not even notice the "cost", so better check twice than miss a check.

thanks, btw, for updating for this. I ditched creative mode despite the convenience for testing because of this sort of crash in mods that don't cope with creative mode doing ... unexpected things, in the "instant destroy" feature, etc.

4 years ago

Hm, is that so? I use creative mode for testing all my mods, and haven't found any issues with it and my mods, or with it and any other mods I'm testing alongside mine. Though I'm really only using it as a shortcut to the sandbox scenario, and for things like the free power, free items, and instant tech tree.

4 years ago

oh, hey, nice. not everything breaks easily to invalid lua stuff from the API, but safely first and all that. :)

New response