User talk:Xerus: Difference between revisions
m (Welcome!) |
(→Modding_Tutorial/Settings: new section) |
||
Line 4: | Line 4: | ||
If you're unsure where to begin, please see the [[Factorio:Editor_noticeboard|editor noticeboard]], where information on the current objectives and projects of the Wiki may be found. | If you're unsure where to begin, please see the [[Factorio:Editor_noticeboard|editor noticeboard]], where information on the current objectives and projects of the Wiki may be found. | ||
Again, welcome, we hope you contribute as much high quality information as you can. [[User:Gangsir|Gangsir]] ([[User talk:Gangsir|talk]]) - <span style="color:#FF0000">Admin</span> 20:20, 22 July 2017 (UTC) | Again, welcome, we hope you contribute as much high quality information as you can. [[User:Gangsir|Gangsir]] ([[User talk:Gangsir|talk]]) - <span style="color:#FF0000">Admin</span> 20:20, 22 July 2017 (UTC) | ||
== Modding_Tutorial/Settings == | |||
Most of the infomation presented here comes from this post: https://forums.factorio.com/viewtopic.php?f=34&t=32890 | |||
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: | |||
settings.lua | |||
settings-updates.lua | |||
settings-final-fixes.lua | |||
As of 0.15.3 there are 4 types of settings: | |||
bool-setting - true/false | |||
int-setting - a signed 64 bit integer | |||
double-setting - a double precision floating point number | |||
string-setting - a string | |||
Each setting supports the standard prototype properties: | |||
name (string, required) | |||
type (string, required) | |||
localised_name (localised string, optional) | |||
localised_description (localised string, optional) | |||
order (string, optional) | |||
In addition to the standard properties mod settings also contain: | |||
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. | |||
Bool setting properties contain: | |||
default_value (bool, required) | |||
Int setting prototypes contain: | |||
default_value (int, required) | |||
minimum_value (int, optional) | |||
maximum_value (int, optional) | |||
allowed_values (array(int), optional) | |||
Double setting prototypes contain: | |||
default_value (double, required) | |||
minimum_value (double, optional) | |||
maximum_value (double, optional) | |||
allowed_values (array(double), optional) | |||
String setting prototype contain: | |||
default_value (string, required) | |||
allow_blank (boolean, optional) - defaults to false | |||
allowed_values (array(string), optional) | |||
Mod settings persistence: | |||
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. | |||
Accessing mod settings through script: | |||
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 display order: | |||
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. |
Latest revision as of 14:35, 23 July 2017
Welcome to the Official Factorio Wiki! Now that you have an account, there are a few key places on this Wiki that will be helpful in your efforts to improve it. First and foremost, please be sure to read and understand the rules of this Wiki. If you have any questions or concerns with these rules, please don't hesitate to ask an Admin. Secondly, if you're new to editing Wikis and are unfamiliar with MediaWiki's formatting, please be sure to read the help pages. If you're unsure where to begin, please see the editor noticeboard, where information on the current objectives and projects of the Wiki may be found. Again, welcome, we hope you contribute as much high quality information as you can. Gangsir (talk) - Admin 20:20, 22 July 2017 (UTC)
Modding_Tutorial/Settings
Most of the infomation presented here comes from this post: https://forums.factorio.com/viewtopic.php?f=34&t=32890
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:
settings.lua settings-updates.lua settings-final-fixes.lua
As of 0.15.3 there are 4 types of settings:
bool-setting - true/false int-setting - a signed 64 bit integer double-setting - a double precision floating point number string-setting - a string
Each setting supports the standard prototype properties:
name (string, required) type (string, required) localised_name (localised string, optional) localised_description (localised string, optional) order (string, optional)
In addition to the standard properties mod settings also contain:
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.
Bool setting properties contain:
default_value (bool, required)
Int setting prototypes contain:
default_value (int, required) minimum_value (int, optional) maximum_value (int, optional) allowed_values (array(int), optional)
Double setting prototypes contain:
default_value (double, required) minimum_value (double, optional) maximum_value (double, optional) allowed_values (array(double), optional)
String setting prototype contain:
default_value (string, required) allow_blank (boolean, optional) - defaults to false allowed_values (array(string), optional)
Mod settings persistence:
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.
Accessing mod settings through script:
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 display order:
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.