raiguard / RecipeBook

Recipe Book for Factorio.
MIT License
20 stars 9 forks source link

error on_load() #108

Closed Yokmp closed 2 years ago

Yokmp commented 2 years ago

Describe the Bug

I have no idea what happened.

To Reproduce

Just loaded into a save and this popped up in a window:

Die Mod Bauplanbuch (3.3.2) hat einen Fehler verursacht, der nicht behoben werden kann.
Bitte informiere den Autor der Mod über diesen Fehler.

Error while running event RecipeBook::on_load()
__RecipeBook__/scripts/database/technology.lua:37: attempt to index local 'recipe_data' (a nil value)
stack traceback:
    __RecipeBook__/scripts/database/technology.lua:37: in function 'technology'
    __RecipeBook__/scripts/database.lua:69: in function 'build'
    __RecipeBook__/control.lua:192: in function <__RecipeBook__/control.lua:185>

Save file & Username

Username: Yokmp cb-aio.zip

IF YOU DO NOT UPLOAD A SAVE FILE AND PROVIDE YOUR USERNAME, THE BUG REPORT WILL BE IGNORED UNTIL YOU DO.

Log file

factorio-current.log

raiguard commented 2 years ago

Did you change mod contents without updating the version? That's the only possible way this could have happened that I can think of.

Yokmp commented 2 years ago

Yes i did change some code at that time. Didn't thought about it uses control to get every recipe without like softdepend on every mod. Is there a force reset command?

raiguard commented 2 years ago

Recipe Book regenerates all of its data during on_load to significantly decrease its script data footprint. Because of this, if you add a recipe and then make an existing tech unlock it, the recipe won't exist in recipe book's database, but the LuaTechnologyPrototype will point to it. Adding validity checks everywhere would make the already complex database code even more complex. The only proper fix for this would be to make the prototype lists readable during on_load, which would be up to the Factorio developers.