Nuclear Science 2.1 Fork


Adds nuclear science as Nauvis's science pack

Content
a month ago
2.1
465
Manufacturing

b attempt to perform arithmetic on field 'energy_required' (a nil value)

a month ago
(updated a month ago)

30.911 Error ModManager.cpp:1786: Failed to load mod "atan-nuclear-science-fork": atan-nuclear-science-fork/functions.lua:56: attempt to perform arithmetic on field 'energy_required' (a nil value)
stack traceback:
atan-nuclear-science-fork/functions.lua:56: in function 'double_time'
atan-nuclear-science-fork/prototypes/recipe-updates.lua:42: in main chunk
[C]: in function 'require'
atan-nuclear-science-fork/data-updates.lua:5: in main chunk

logged before line 42, happens at recipe "thorium-extraction"... not sure where that recipe's from, got a ton of mods installed...

EDIT
seems to be this guy: https://github.com/Frontrider/dea-dia-system/blob/5a7101418fe365c0467c62c5abd3857825c8d1da/prototype/content/prosephina/thorium.lua#L50
although that's not 2.1 yet, which is why I installed https://mods.factorio.com/mod/dea-dia-system-beomyo which is proably identical wrt "thorium-extraction".

I'm not sure if it's fair that they omit energy_required, but according to https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html#energy_required it's optional and apparently would default to 0.5.

It seems, to me, that you would have to handle that case, so if not set then recipe.energy_required = 2*0.5 in line 56 in M.recipe.double_time in functions.lua...

Hope this helps. Thanks for forking to 2.1! :-)

a month ago
(updated a month ago)

Sorry for the delay, I've been super sick lately.

I'll have to take a deeper look at it when I'm feeling better, but so far I'm not quite sure how to fix it from this side right now. When energy_required is not defined in the recipe, it defaults to .5 but only towards end of loading, and this mod tries to edit that value before it is set.
I poked around at setting dependencies to try to force it to load after, but didn't have any success, and I have run out of time today.

For a simple stopgap fix, you can comment out lines 40-44 in this mod's prototypes/recipe_updates.lua
it'll get rid of the original recipe time doubling, but at least it'll let you play for now

a month ago

thanks for you reply, no worries! hope you get well soon!

I replaced functions.lua#56 with this:
recipe.energy_required = 2 * (recipe.energy_required or 0.5)

and Factorio starts, but I don't know whether that's a good way to do it...

a month ago

Did a bit of testing and that certainly seems to be a good solution to undefined recipes without changing anything else, and I managed to find another issue to fix while I was at it.

Clearly there are way too many holes in my lua knowledge, thank you for the fix!
I'll get that posted shortly

New response