[0.15] Mod setting/config interface - give your input

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Rseding91 »

sparr wrote:
Rseding91 wrote:Where did "per_user" come from? It's not used in any context when it comes to mod settings.
Artifact of people trying to follow the original not-really-documentation from this thread, and a bunch of examples based on that.
Ah. Well I've updated the main post with correct information :)
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Mooncat »

Here's my big thanks to those who reverse engineered Factorio so we can implement mod settings before the official doc is ready.
And thank you Rseding for implementing this amazing setting system and the official doc. :D

So far so good. That 4 types of settings are very useful. I believe we can leave the other advanced types like item-setting, color-setting, list-setting for the future.

It would be more handy if int-setting and double-setting display a slider when minimum_value and maximum_value are defined but not allowed_values. :mrgreen:
If it is implemented, please also consider an option for making the slider non-linear (something like the slider of logistic request item count).

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by orzelek »

Thanks to all posters here for explanations and examples - RSO will be getting bunch of settings based on this.

I would also like to propose a dummy setting - I'd like to have a short warning displayed around some of settings. It would be good to have a setting without value that we could simply add and position with order sort.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Rseding91 »

orzelek wrote:Thanks to all posters here for explanations and examples - RSO will be getting bunch of settings based on this.

I would also like to propose a dummy setting - I'd like to have a short warning displayed around some of settings. It would be good to have a setting without value that we could simply add and position with order sort.
Settings can have descriptions (tooltips) so you can easily set those up. They will display when you hover over the setting name in the GUI.
If you want to get ahold of me I'm almost always on Discord.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by orzelek »

Rseding91 wrote:
orzelek wrote:Thanks to all posters here for explanations and examples - RSO will be getting bunch of settings based on this.

I would also like to propose a dummy setting - I'd like to have a short warning displayed around some of settings. It would be good to have a setting without value that we could simply add and position with order sort.
Settings can have descriptions (tooltips) so you can easily set those up. They will display when you hover over the setting name in the GUI.
I did use those. I'm still expecting bug reports based on general rule that users don't read all the stuff just skim over it ;)

Idea was to have warning directly on list not on mouse over.
I added also direct print in game after setting change and I'm hoping it will be enough.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Optera »

orzelek wrote:
Rseding91 wrote:
orzelek wrote:Thanks to all posters here for explanations and examples - RSO will be getting bunch of settings based on this.

I would also like to propose a dummy setting - I'd like to have a short warning displayed around some of settings. It would be good to have a setting without value that we could simply add and position with order sort.
Settings can have descriptions (tooltips) so you can easily set those up. They will display when you hover over the setting name in the GUI.
I did use those. I'm still expecting bug reports based on general rule that users don't read all the stuff just skim over it ;)

Idea was to have warning directly on list not on mouse over.
I added also direct print in game after setting change and I'm hoping it will be enough.
wouldn't be a bad idea, I already have "bug" reports from users who didn't manually reset the mod settings. :roll:

credomane
Filter Inserter
Filter Inserter
Posts: 278
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by credomane »

Rseding91 wrote:
  • localised_name (localised string, optional)
  • localised_description (localised string, optional)
What purpose do these serve?
Shouldn't they be in locale/{language}/locale.cfg? Otherwise you can only do a single language...or is that outdated doc?

Time to poke about some mods that make use of settings.lua. :D

[edit]
Seems to be outdated.

Sample settings.lua

Code: Select all

data:extend({
  {
    name = "my-setting-name",
    type = "bool-setting",
    setting_type = "runtime-per-user",
    default_value = true,
  },
})
Sample locale/en/locale.cfg

Code: Select all

[mod-setting-name]
my-setting-name=Localized setting name

[mod-setting-description]
my-setting-name=Localized setting description


folk
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by folk »

It's if you want to explicitly override the localized name or description, or you want to use some other key than [mod-setting-name/description].setting-name.
You could for example use the same l10n string for an item/recipe/whatever and the setting.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Optera »

I mostly need localised_name when populating data.raw with a script.
Setting different ore richness for any ore added by mods would be a possible scenario.

credomane
Filter Inserter
Filter Inserter
Posts: 278
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by credomane »

folk wrote:It's if you want to explicitly override the localized name or description, or you want to use some other key than [mod-setting-name/description].setting-name.
You could for example use the same l10n string for an item/recipe/whatever and the setting.
Optera wrote:I mostly need localised_name when populating data.raw with a script.
Setting different ore richness for any ore added by mods would be a possible scenario.
Ah...That makes sense. Thanks you two!

User avatar
mickael9
Fast Inserter
Fast Inserter
Posts: 112
Joined: Mon Mar 14, 2016 4:04 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by mickael9 »

Did I miss something or we can't have a multiple choice combo box setting (string or int type) with localized values?

swni
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Sat Mar 05, 2016 1:54 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by swni »

No localized values for multiple choice combo, unfortunately.

Also like orzelek and others I would like to have a way to put up just explanatory text. In my case I'm not using a mouseover box because I want to include a link to an image gallery. Instead I plan on using a string input with a single allowed value that just says "Ok!" or something.

folk
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by folk »

Can we perhaps get a setting for string-setting that ensures whitespace is trimmed from the input?
Trim obviously means start and end, so " test " would become "test".

It might be useful to have the ability to set a validate function on the setting, like

Code: Select all

	{
		type = "string-setting",
		name = "folk-shuttle-ignore-stations",
		setting_type = "runtime-per-user",
		default_value = "",
		allow_blank = true,
		validate = function(input)
			return not input:find("%s")
		end,
	}
Or similar. Obviously the example given above is only for demonstration.
It could also just be a string property like allowed_pattern="%S" that the engine matches towards given input before accepting it. Or forbidden_pattern=. Or both.
http://www.lua.org/manual/5.2/manual.html#6.4.1

Alternatively, allow mods to manipulate LuaSettings to fix any weird input that should not be allowed. This might be possible already? I haven't tried.

Would it be possible for settings.get_player_settings(p)[setting].value to be nil for empty string-settings? It's more efficient for us to check |if setting then| than |if setting and setting:len() ~= 0 then|. Not really important.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Rseding91 »

I'll add support to localize each dropdown option as well as support to auto-trim manual strings.
If you want to get ahold of me I'm almost always on Discord.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by sparr »

folk wrote:

Code: Select all

		validate = function(input)
			return not input:find("%s")
		end,
I love this idea. It is so much more flexible than just having a list. Brainstorm ideas that would use this:

input with no spaces
input that is a valid filename
input that is the name of an item / technology (until we get a data picker input type)
input that is 4-8 characters long
input that is a checksum-valid credit card number (ha!)

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by justarandomgeek »

A color setting type would be useful, with a color-picker GUI and returning the {r,g,b,a} table (or just {r,g,b}?).

folk
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by folk »

justarandomgeek wrote:A color setting type would be useful, with a color-picker GUI and returning the {r,g,b,a} table (or just {r,g,b}?).
Until then, for https://mods.factorio.com/mods/folk/folk-colorequipment I just allow inputs of comma-separated rgb hex values, which allows easy copying from sources like https://www.materialui.co/flatuicolors (expand the sidebar, click a color to copy to clipboard at least on linux).
data.lua: https://hastebin.com/yakulajata.lua
control.lua: https://hastebin.com/ojalozaned.lua
parse.lua: https://hastebin.com/taruvuxeba.lua
I've not fuzzed the rgb-hex parser or even tested it extensively to make sure it doesn't break on weird input, but it seems to do alright.

I don't know if inputting "HTML" color codes is easier than 0-1 - or whatever else - for normal people, but I prefer it.

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by justarandomgeek »

folk wrote:
justarandomgeek wrote:A color setting type would be useful, with a color-picker GUI and returning the {r,g,b,a} table (or just {r,g,b}?).
Until then, for https://mods.factorio.com/mods/folk/folk-colorequipment I just allow inputs of comma-separated rgb hex values, which allows easy copying from sources like https://www.materialui.co/flatuicolors (expand the sidebar, click a color to copy to clipboard at least on linux).
data.lua: https://hastebin.com/yakulajata.lua
control.lua: https://hastebin.com/ojalozaned.lua
parse.lua: https://hastebin.com/taruvuxeba.lua
I've not fuzzed the rgb-hex parser or even tested it extensively to make sure it doesn't break on weird input, but it seems to do alright.

I don't know if inputting "HTML" color codes is easier than 0-1 - or whatever else - for normal people, but I prefer it.
I (obviously) opted for the clunkier but more-data-pure choice of using four doubles with names suffixed -r,-g,-b,-a for each color setting. I should probably go back and properly limit them to 0-1 though...

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by Rseding91 »

I'm definitely going to be adding more mod setting types once this initial wave of 0.15 bugs is taken care of. Probably another 2 weeks and then I'll start on stuff like this.

Right now setting types I'm going to add are:
  • Prototype picker (any prototype type) - which will simply give the string prototype name but the GUI will have a drop-down of all options
  • Color picker (similar to the train one but with alpha as well)
If you want to get ahold of me I'm almost always on Discord.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [0.15] Mod setting/config interface - give your input

Post by sparr »

Rseding91 wrote:Prototype picker (any prototype type) - which will simply give the string prototype name but the GUI will have a drop-down of all options
How about a signal picker?

Post Reply

Return to “Modding discussion”