Deadlock989 / IndustrialRevolution

Industrial Revolution 3 is an overhaul mod for Factorio.
51 stars 0 forks source link

Error loading mods - issue in 'calculate_scraps' attempts to compare number with string #418

Closed TeraBitGaming closed 2 months ago

TeraBitGaming commented 2 months ago

Describe the issue I was (re)setting my load order to restart an IR3 playthrough, when I got a popup after reloading stating there's an issue in 'calculate_scraps' for lines 65 and 75 of functions-data-scrapping.lua. The stacktrace looks like this: image I reinstalled IR3 and verified Factorio's files, but this error kept popping up.

Factorio version, IR version Factorio is the most recent version; 1.1.107 IR3 is the most recent version; 3.1.22

Other mods installed The other non-QOL mods I run are: Armor Pockets Circuit HUD V2 Larger lamps Recursive Blueprints Selector Combinator (Factorio 2.0 preview) Simple Landfill Mining Text Plates Wire Shortcuts

I have more, but I'm unsure what qualifies as a QoL mod and what doesn't, I can easily add the entire load order if that's desired. If more information is needed, I will gladly provide since this is such a good mod and I'd love to play again.

Deadlock989 commented 2 months ago

The culprit is Armor Pockets, which is apparently using the value of a string setting to set an ingredient amount in a recipe, rather than an int setting or a double setting, or converting the string value into a number. This is technically wrong according to the prototype spec, but Factorio seems to allow it. I will have to think about how to handle it - that won't be for a week or so, in the meantime you can work around it by disabling Armor Pockets.

TeraBitGaming commented 2 months ago

Thanks for your quick response, is it a good idea to inform the author of armor pockets too? Ergo, do you think there's a workaround Armor Pockets could implement to fix this issue?

Deadlock989 commented 2 months ago

Lua has a couple of ways of converting string values into explicit numbers, e.g. the built in tonumber() function. But AP hasn't been updated for over 3 years and I can see on the mod portal discussion page that people were reporting this issue even for IR2, so I'm not sure whether it's worth your time reporting it again. No-one has previously reported it to me.

Deadlock989 commented 2 months ago

If you are playing IR3 single player then you can hotfix your own local copy of the mod by editing code/functions/functions-data-scrapping.lua, changing line 13 from:

if name == item and amount then return amount end

to:

if name == item and type(amount) == "number" then return amount end