Science Pack Galore (Forked)


Add lots of types of science packs to spice up your set-ups with additional production lines! Includes 36 new science packs.

Content
10 months ago
1.1
612

g tech_order_reverse is borked

a month ago
(updated a month ago)

Hello big forker boss. Your mod works wonders by itself, and with science pack bonanza, but, if I shove them both in the All the Overhauls modpack, suddenly the game doesn't finish loading and it says this:
"Failed to load mods: prototypes/technology/recipe-preprocess.lua:12: attempt to compare two nil values"

So, since I know next to nothing about coding, I did the next best thing, and I asked an ai, Claude, and I got this answer:

"Here's what's happening:

  1. tech_order_reverse is initialized in preprocess-replacement.lua and preprocess.lua.
  2. unlocking_tech is being populated in the same file (recipe-preprocess.lua) where the error occurs.

The issue likely stems from one of these scenarios:

  1. effect.recipe is not a valid key in unlocking_tech
  2. key is nil
  3. Either unlocking_tech[effect.recipe] or key is not present in tech_order_reverse

To fix this, you should add some nil checks and error handling. Here's a suggested modification:
if unlocking_tech[effect.recipe] then
local tech1 = tech_order_reverse[unlocking_tech[effect.recipe]]
local tech2 = tech_order_reverse[key]
if tech1 and tech2 then
if tech1 > tech2 then
unlocking_tech[effect.recipe] = key
end
else
log("Warning: Missing tech order for " .. tostring(unlocking_tech[effect.recipe]) .. " or " .. tostring(key))
end
else
unlocking_tech[effect.recipe] = key
end

This modification:

  1. Checks if unlocking_tech[effect.recipe] exists before trying to use it.
  2. Retrieves the values from tech_order_reverse separately.
  3. Checks if both values exist before comparing them.
  4. Logs a warning if either technology is missing from tech_order_reverse.
  5. Sets unlocking_tech[effect.recipe] to key if it didn't exist before.

Additionally, you might want to add some debug logging to understand why these values might be nil:

log("Debug: effect.recipe = " .. tostring(effect.recipe))
log("Debug: unlocking_tech[effect.recipe] = " .. tostring(unlocking_tech[effect.recipe]))
log("Debug: key = " .. tostring(key))

Place these log statements before the comparison to get more information about the values when the error occurs.
If the issue persists, you may need to investigate why tech_order_reverse doesn't contain all the expected keys. Check the code in preprocess-replacement.lua and preprocess.lua where tech_order_reverse is populated to ensure all technologies are being added correctly."

Anyways, GL HF figuring this issue.

a month ago

Oh, damn, I forgot to change the category to bug.

New response