I know that info is outdated, but I wanted to point out that it seems like settings require globally unique names now? When I query a setting I don't have to specify which mod it belongs to. This seems like a bad idea that's going to cause problems with conflicting names. Maybe settings should be segregated per mod and queryable that way?Rseding91 wrote:"double-player-health" is a way to identify this setting. This is required to be unique per-mod.
[0.15] Mod setting/config interface - give your input
Re: [0.15] Mod setting/config interface - give your input
Re: [0.15] Mod setting/config interface - give your input
I notice that if I set a "double" setting to an integer value, it displays as the integer. If the default for a double setting is an integer value, the user might never realize it can be non-integer.
Suggestion: double values always display with a trailing ".0" for integer values
Suggestion: double values always display with a trailing ".0" for integer values
Re: [0.15] Mod setting/config interface - give your input
Nothing else in the game is split per-mod: entities, items, fluids, and so on. Making them split per mod was going to quadruple or more the complexity to implement the settings so I decided against it.sparr wrote:I know that info is outdated, but I wanted to point out that it seems like settings require globally unique names now? When I query a setting I don't have to specify which mod it belongs to. This seems like a bad idea that's going to cause problems with conflicting names. Maybe settings should be segregated per mod and queryable that way?Rseding91 wrote:"double-player-health" is a way to identify this setting. This is required to be unique per-mod.
Simply prefix your settings with some unique identifier for your mod and it works fine.
If you want to get ahold of me I'm almost always on Discord.
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: [0.15] Mod setting/config interface - give your input
The only "documentation" that exists for Factorio prototypes is "copy the base game definitions". Since the test mod that contains the only base example of mod-settings does not contain an instance of the "order" property, you'll have to excuse me for not immediately assuming its existence as a valid property.Rseding91 wrote:It's a core part of how the entire prototype system works in Factorio. If you don't know that it exists then you probably haven't been doing anything with modding in Factorio
Re: [0.15] Mod setting/config interface - give your input
Another gui bug:
Double scroll for settings and for GUI container
Double scroll for settings and for GUI container
screenshot
So my suggestion to add mod list and limit max height looks more valuable. Re: [0.15] Mod setting/config interface - give your input
Lack of documentation has been a problem but thankfully folk's work was enough to get me started, although I still have some questions. So far this is what I've figured out (partially from what other people have said and partially from experimentation):
Settings are created by extending data.raw. Use data:extend{<Setting1>, <Setting2>, ..., <SettingN>} where each <Setting> is a lua table with some of the following keys: type, name, setting_type, default_value, minimum_value, maximum_value, order, allowed_values, per_user.
"type" should be one of "int-setting", "bool-setting", "double-setting", or "string-setting".
"name" should be a string unique across all mods. This name is used in the locale configuration, and to retrieve the setting's value as described below.
"setting_type" should be "startup", "runtime-global", or "runtime-per-user".
"allowed_values" a list of values, and can be used with string and int types to make a drop down menu
"per_user" is a bool; best guess is it doesn't do anything (i.e., don't use it)
"startup" settings are accessible only in data.lua, and not in control.lua. They are accessed with settings.startup[<SettingName>].value. (Of course, one can use data.lua to copy the startup settings into a dummy entity to make the startup settings visible from control.lua, using the same trick as sparr's "Expose data.raw" mod that makes data.raw visible within control.lua.) startup has nothing to do with a new game starting as I had assumed at first, but refers to the Factorio binary starting. Changing startup settings causes Factorio to restart.
"runtime-per-user" and "runtime-global" settings are accessible only in control.lua and not in data.lua. The former are accessed with settings.global[<SettingName>].value, and the latter with settings.get_player_settings(<LuaPlayer>)[<SettingName>].value.
Locale configuration for "[mod-setting-name]" controls the label for the gui element visible to the user when choosing the value for the setting, and "[mod-setting-description]" controls the tooltip.
I'm fairly sure that if you load a saved game with different settings than it was saved with, the new settings are used and old ones forgotten, although I haven't tested this carefully. This makes it a bit tricky to have different saves going with different settings, but not any trickier than it was before. I haven't had a chance to see what happens if you try to join a multiplayer game with different settings; I assume local settings are changed to agree with the server and, if that includes startup settings, a restart is triggered.
So that leaves me with two main questions: How do you access runtime-global settings, and what does the per_user option do?
Settings are created by extending data.raw. Use data:extend{<Setting1>, <Setting2>, ..., <SettingN>} where each <Setting> is a lua table with some of the following keys: type, name, setting_type, default_value, minimum_value, maximum_value, order, allowed_values, per_user.
"type" should be one of "int-setting", "bool-setting", "double-setting", or "string-setting".
"name" should be a string unique across all mods. This name is used in the locale configuration, and to retrieve the setting's value as described below.
"setting_type" should be "startup", "runtime-global", or "runtime-per-user".
"allowed_values" a list of values, and can be used with string and int types to make a drop down menu
"per_user" is a bool; best guess is it doesn't do anything (i.e., don't use it)
"startup" settings are accessible only in data.lua, and not in control.lua. They are accessed with settings.startup[<SettingName>].value. (Of course, one can use data.lua to copy the startup settings into a dummy entity to make the startup settings visible from control.lua, using the same trick as sparr's "Expose data.raw" mod that makes data.raw visible within control.lua.) startup has nothing to do with a new game starting as I had assumed at first, but refers to the Factorio binary starting. Changing startup settings causes Factorio to restart.
"runtime-per-user" and "runtime-global" settings are accessible only in control.lua and not in data.lua. The former are accessed with settings.global[<SettingName>].value, and the latter with settings.get_player_settings(<LuaPlayer>)[<SettingName>].value.
Locale configuration for "[mod-setting-name]" controls the label for the gui element visible to the user when choosing the value for the setting, and "[mod-setting-description]" controls the tooltip.
I'm fairly sure that if you load a saved game with different settings than it was saved with, the new settings are used and old ones forgotten, although I haven't tested this carefully. This makes it a bit tricky to have different saves going with different settings, but not any trickier than it was before. I haven't had a chance to see what happens if you try to join a multiplayer game with different settings; I assume local settings are changed to agree with the server and, if that includes startup settings, a restart is triggered.
Last edited by swni on Thu Apr 27, 2017 11:26 pm, edited 1 time in total.
Re: [0.15] Mod setting/config interface - give your input
Yeah, and since most of my modding didn't involve touching prototypes it was a long time before I knew about the "order" property anyhow. By the way, where did you find the test mod? The only example I've been working off of is folk's.Supercheese wrote:The only "documentation" that exists for Factorio prototypes is "copy the base game definitions". Since the test mod that contains the only base example of mod-settings does not contain an instance of the "order" property, you'll have to excuse me for not immediately assuming its existence as a valid property.Rseding91 wrote:It's a core part of how the entire prototype system works in Factorio. If you don't know that it exists then you probably haven't been doing anything with modding in Factorio
Re: [0.15] Mod setting/config interface - give your input
swni wrote:So that leaves me with two main questions: How do you access runtime-global settings, and what does the per_user option do?
Code: Select all
settings.global['name_of_setting'].value
Re: [0.15] Mod setting/config interface - give your input
Test mod is only packaged with some versions of Factorio. It's in the program directory (where data/base and data/core live) under tests/mods or similar. I don't have it, because it's not packaged with the OSX Steam version of the game. Some folks elsewhere linked a zip for it.swni wrote:By the way, where did you find the test mod? The only example I've been working off of is folk's.
Re: [0.15] Mod setting/config interface - give your input
Thanks much for the quick and clear answers. Yeah, I don't have the test mod either (linux). I'll edit my post so that I can use it as a reference for myself, in lieu of documentation existing elsewhere.
Re: [0.15] Mod setting/config interface - give your input
It would be awesome if the 3-4 people in this thread who are slowly reverse engineering how the settings stuff works would collaboratively edit a wiki page.
https://wiki.factorio.com/
https://wiki.factorio.com/
Re: [0.15] Mod setting/config interface - give your input
swni wrote:Lack of documentation has been a problem but thankfully folk's work was enough to get me started, although I still have some questions. So far this is what I've figured out (partially from what other people have said and partially from experimentation):
Settings are created by extending data.raw. Use data:extend{<Setting1>, <Setting2>, ..., <SettingN>} where each <Setting> is a lua table with some of the following keys: type, name, setting_type, default_value, minimum_value, maximum_value, order, allowed_values, per_user.
"type" should be one of "int-setting", "bool-setting", "double-setting", or "string-setting".
"name" should be a string unique across all mods. This name is used in the locale configuration, and to retrieve the setting's value as described below.
"setting_type" should be "startup", "runtime-global", or "runtime-per-user".
"allowed_values" a list of values, and can be used with string and int types to make a drop down menu
"per_user" is a bool; best guess is it doesn't do anything (i.e., don't use it)
"startup" settings are accessible only in data.lua, and not in control.lua. They are accessed with settings.startup[<SettingName>].value. (Of course, one can use data.lua to copy the startup settings into a dummy entity to make the startup settings visible from control.lua, using the same trick as sparr's "Expose data.raw" mod that makes data.raw visible within control.lua.) startup has nothing to do with a new game starting as I had assumed at first, but refers to the Factorio binary starting. Changing startup settings causes Factorio to restart.
"runtime-per-user" and "runtime-global" settings are accessible only in control.lua and not in data.lua. The former are accessed with settings.global[<SettingName>].value, and the latter with settings.get_player_settings(<LuaPlayer>)[<SettingName>].value.
Locale configuration for "[mod-setting-name]" controls the label for the gui element visible to the user when choosing the value for the setting, and "[mod-setting-description]" controls the tooltip.
I'm fairly sure that if you load a saved game with different settings than it was saved with, the new settings are used and old ones forgotten, although I haven't tested this carefully. This makes it a bit tricky to have different saves going with different settings, but not any trickier than it was before. I haven't had a chance to see what happens if you try to join a multiplayer game with different settings; I assume local settings are changed to agree with the server and, if that includes startup settings, a restart is triggered.
So that leaves me with two main questions: How do you access runtime-global settings, and what does the per_user option do?
"default_value" - default value sets a default for int, double, string and bool
"maximum_value" - maximum allowed value for int and double
"minimum_value" - minimum allowed value for int and double
I'm curious what per_user does myself.
My Mods: mods.factorio.com
Re: [0.15] Mod setting/config interface - give your input
I think per_user means any user can change their user_runtime setting. Whereas if it is false only admin can change??? Haven't tested these with MP yet but I may soon
Re: [0.15] Mod setting/config interface - give your input
Only Admins can change settings regardless of per_user.Nexela wrote:I think per_user means any user can change their user_runtime setting. Whereas if it is false only admin can change??? Haven't tested these with MP yet but I may soon
Any Idea why changing global settings in MP keeps crashing the host with "Attempting to save empty mod settings."?
viewtopic.php?f=7&t=45395
My Mods: mods.factorio.com
Re: [0.15] Mod setting/config interface - give your input
runtime-per-user can be changed by users
runtime-global by admins
startup by anyone before world loads, if your startup doesn't you will be prompted to restart with those settings
So back to not having any clue what the per_user variable does
runtime-global by admins
startup by anyone before world loads, if your startup doesn't you will be prompted to restart with those settings
So back to not having any clue what the per_user variable does
Re: [0.15] Mod setting/config interface - give your input
Startup settings are available for reading in control.lua without any fanceryswni wrote: "startup" settings are accessible only in data.lua, and not in control.lua. They are accessed with settings.startup[<SettingName>].value. (Of course, one can use data.lua to copy the startup settings into a dummy entity to make the startup settings visible from control.lua, using the same trick as sparr's "Expose data.raw" mod that makes data.raw visible within control.lua.) startup has nothing to do with a new game starting as I had assumed at first, but refers to the Factorio binary starting. Changing startup settings causes Factorio to restart.
/c game.print(settings.startup["picker-unminable-logistic-robots"].value)
Re: [0.15] Mod setting/config interface - give your input
@rseding91
When joining an MP game with different startup settings it has you restart with those settings enabled. Any chance you could put it on your todo list to make this a temporary change where the next restart afterwards will revert to what they were before?
When joining an MP game with different startup settings it has you restart with those settings enabled. Any chance you could put it on your todo list to make this a temporary change where the next restart afterwards will revert to what they were before?
Re: [0.15] Mod setting/config interface - give your input
Idea:
Add chain activation and new field: prerequisites = {name, condition}.
In other words - if some settings need some prerequisites before they can be used like techs.
Add chain activation and new field: prerequisites = {name, condition}.
In other words - if some settings need some prerequisites before they can be used like techs.
Re: [0.15] Mod setting/config interface - give your input
Where did "per_user" come from? It's not used in any context when it comes to mod settings.Nexela wrote:runtime-per-user can be changed by users
runtime-global by admins
startup by anyone before world loads, if your startup doesn't you will be prompted to restart with those settings
So back to not having any clue what the per_user variable does
As for documentation: I'll finish when I've got today and put it in the main post.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.15] Mod setting/config interface - give your input
Artifact of people trying to follow the original not-really-documentation from this thread, and a bunch of examples based on that.Rseding91 wrote:Where did "per_user" come from? It's not used in any context when it comes to mod settings.