Brave New World

by canidae

RTS-like scenario for Factorio. Player character is removed, all work must be done by bots

Scenarios
2 years ago
0.16 - 1.1
8.12K

b Crash because of non-existing setting [TODO]

2 years ago
(updated 2 years ago)

Hi! While working on my character selector mod, I've found a bug that probably won't occur in a real game. I've never seen anything like that before. Guess it happened because yours is not a normal mod, but a scenario.

Reproduce:

  • Start a new game with your mod enabled, using your scenario.
  • Save the game.
  • Disable your mod, enforcing a restart of the game.
  • Load the saved game (this works alright).
  • Escape to the main menu and click on "Restart".
  • Crash:

    Error while running event level::on_player_created (ID 25)
    ...mes/Factorio/test_1.1/temp/currently-playing/control.lua:304: attempt to index field 'bnw-homeworld-starting-robots' (a nil value)
    stack traceback:
    ...mes/Factorio/test_1.1/temp/currently-playing/control.lua:304: in function 'setupForce'
    ...mes/Factorio/test_1.1/temp/currently-playing/control.lua:463: in function <...mes/Factorio/test_1.1/temp/currently-playing/control.lua:428>

As the game has been restarted without your mod, settings.startup["bnw-homeworld-starting-robots"] (line 304) and settings.startup["bnw-homeworld-starting-robots"] (line 309) are undefined. Because the control file from temp/currently-playing is used, trying to read these settings value will trigger the crash.

You could add a check for the settings before trying to read their values. But considering that your mod isn't used anymore, it seems to make more sense to add the following at the top of your control.lua:

if not script.active_mods["brave-new-world"] then
  return
end
2 years ago

That's an elaborate bug scenario, but also not that hard of a fix. :-) Thanks!

New response