[0.15] Mod setting/config interface - give your input
Posted: Sun Sep 18, 2016 6:41 am
Mod settings:
Do not conditionally 'require(...)' things: this breaks the crc checks and people will get errors trying to use your mod in multiplayer. 'require(...)' everything and then conditionally add the values to data.raw using the settings.
Mod settings are defined per-mod using the same process as normal prototypes with their own settings files.
See the data stage here: http://lua-api.factorio.com/latest/Data-Lifecycle.html
The settings lua files are:
Do not conditionally 'require(...)' things: this breaks the crc checks and people will get errors trying to use your mod in multiplayer. 'require(...)' everything and then conditionally add the values to data.raw using the settings.
Mod settings are defined per-mod using the same process as normal prototypes with their own settings files.
See the data stage here: http://lua-api.factorio.com/latest/Data-Lifecycle.html
The settings lua files are:
- settings.lua
- settings-updates.lua
- settings-final-fixes.lua
- bool-setting - true/false
- int-setting - a signed 64 bit integer
- double-setting - a double precision floating point number
- string-setting - a string
- name (string, required)
- type (string, required)
- localised_name (localised string, optional)
- localised_description (localised string, optional)
- order (string, optional)
- setting_type (string, required)
- "startup" - this setting type is available during the standard prototype data loading stage and can't be changed runtime. When joinin a server the startup settings are required to be identical to the server and if not the joining person will be asked if they want to set their settings to match the server.
- "runtime-global" - this setting type is only available runtime in the control.lua stage and can only be changed by admins (or in single player the 1 player).
- "runtime-per-user" - this setting type is only available runtime in the control.lua stage and each player has their own instance of this setting. When a player joins a server their local setting of "keep mod settings per save" determines if the local settings they have set are synced to the loaded save or if the save settings are used.
- default_value (bool, required)
- default_value (int, required)
- minimum_value (int, optional)
- maximum_value (int, optional)
- allowed_values (array(int), optional)
- default_value (double, required)
- minimum_value (double, optional)
- maximum_value (double, optional)
- allowed_values (array(double), optional)
- default_value (string, required)
- allow_blank (boolean, optional) - defaults to false
- allowed_values (array(string), optional)
- The "mod-settings.json" file stored in the write-data folder for the game contains the local players settings between game sessions similar to the player-data.json file.
- The global property "settings" is populated with the startup settings during the data loading stage. Runtime (the control.lua stage) the global property "settings" contains startup, runtime, and runtime-per-user settings in read-only format.
- Mod settings are shown in the settings GUI first sorted by mod sort order then sorted by the setting "order" string and then finally by the setting name.
outdated