Page 1 of 1

Error when using color-setting for runtime-per-user setting

Posted: Tue May 30, 2023 9:28 pm
by Pi-C
I've got a report that updating Autodrive from version 1.1.4 to 1.1.5 would reset all settings to their default values. Apparently, the same happened when updating GCKI from version 1.1.5 to 1.1.6 some days earlier.

There is one change that both mods have in common: They used to have a runtime-per-user setting for selecting a color where you could select predefined colors via a string-setting, which I've changed to a color-setting. This is how I define the color-setting in Autodrive:

Code: Select all

  {   -- Render color
    type = "color-setting",
    name = "autodrive-render-color",
    setting_type = "runtime-per-user",
    default_value = {r = 1.000, g = 0.630, b = 0.259, a = 1},
    order = "[autodrive]-[per-user]-b",
  },
How to reproduce:
  • Start Factorio with Autodrive 1.1.4.
  • Make sure that at least one setting (no matter whether a startup, runtime-global, or runtime-per-user setting) is set to a different value than the default.
  • Restart the game. Open Settings-->Mod settings to confirm that the setting(s) still have the non-default value.
  • Update to Autodrive 1.1.5.
  • Restart the game. When you open Settings-->Mod settings, you'll see that all settings have been reset to their default value.
  • Change any setting, of any type.
  • Edit file settings.lua of Autodrive 1.1.5 and change setting_type of setting "autodrive-render-color" to "runtime-global".
  • Restart the game. Open Settings-->Mod settings to find that the setting(s) still have the non-default value.
  • Edit file settings.lua of Autodrive 1.1.5 and change setting_type of setting "autodrive-render-color" to "startup".
  • Restart the game. Open Settings-->Mod settings to find, once again, that the setting(s) still have the non-default value.
When using Autodrive 1.1.5 when the color-setting was a runtime-per-user-setting, I've found this error message in my log file:

Code: Select all

   1.564 Error GlobalModSettings.cpp:161: Failed to read mod settings: Unsupported color format. Expected a list of 4 values { r, g, b, a } or a dictionary { r = ..., g = ..., b = ..., a = ... }.
This error makes no sense as the default_value of my setting clearly is a dictionary with the expected format, and as the setting doesn't raise an error if a different setting_type is used.

Re: Error when using color-setting for runtime-per-user setting

Posted: Wed May 31, 2023 12:10 am
by Rseding91
The error is coming from trying to load the old mod setting value from the saved player settings. It should reset just the 1 mod setting after the migration finishes but it sounds like it's resetting the entire player settings which is the bug.

Re: Error when using color-setting for runtime-per-user setting

Posted: Wed May 31, 2023 9:57 am
by Rseding91
It's now fixed for the next 1.1.x release.

Re: Error when using color-setting for runtime-per-user setting

Posted: Wed May 31, 2023 11:50 am
by Pi-C
Thank you! :-)