248k Mod


Advance through 4 stages of tech. Start with simple machines and work your way through nuclear fission and fusion up to black and white holes, in order to tame the 248k Element. This mod is designed to be playable in already existing worlds since it changes nothing on world generation. Can be played as a standalone mod or in overhaul mode.

Overhaul
2 months ago
1.0 - 1.1
46.3K

b Conditional 'require' statements

2 years ago
(updated 2 years ago)

Conditional 'require' statements are not allowed in Factorio mods because they cause the same mod version to load with a different code hash (different number of source files loaded) depending startup settings. Joining a multiplayer server will fail if the mod hash is wrong, and it will not sync the mod settings automatically when that happens.

Instead, your must put the IF statement within the file, so that the file is always included in the Lua state but its contents is only executed when the condition is true. Specifically this one in data-final-fixes will be a problem:

if (settings.startup['overhaul_mode'].value == true and mods["Krastorio2"]) then require('scripts/krastorio2/overhaul') end

This is the root cause of this user report: https://forums.factorio.com/viewtopic.php?f=29&t=102335&p=567589#p567589

2 years ago
(updated 2 years ago)

Thanks for the quick fix. This one will also be a problem:

if settings.startup['overhaul_realistic_reactors'].value then require('scripts/realisticreactors/overhaul') end

Edit: and I haven't search the entire repo for other ones that also check settings, so there might be more

All the other ones that check the mods[] list, like
if mods["space-exploration"] then require('scripts/SE/data-final-fixes') end

only work by coincidence because the mod list is synchronized before the Lua hash is compared. Best practice would be to do the same thing to them, so that every require() statement is executed every time, but it doesn't break anything like that right now.

2 years ago

Thanks for the quick fix. This one will also be a problem:

if settings.startup['overhaul_realistic_reactors'].value then require('scripts/realisticreactors/overhaul') end

Edit: and I haven't search the entire repo for other ones that also check settings, so there might be more

All the other ones that check the mods[] list, like
if mods["space-exploration"] then require('scripts/SE/data-final-fixes') end

only work by coincidence because the mod list is synchronized before the Lua hash is compared. Best practice would be to do the same thing to them, so that every require() statement is executed every time, but it doesn't break anything like that right now.

the realistic reactors one should be fixed too.

2 years ago

Looks like it's still in the head of the repo. Even though it's inside the "if mods["RealisticReactors"] then", it's also inside the "if settings.startup['overhaul_realistic_reactors'].value then" block.

2 years ago

Looks like it's still in the head of the repo. Even though it's inside the "if mods["RealisticReactors"] then", it's also inside the "if settings.startup['overhaul_realistic_reactors'].value then" block, so changing the setting will affect whether the file is included.

New response