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

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

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

Post by Rseding91 »

Ok, I've implemented the basic foundation to make mod settings work for 0.15 (see first post).

Right now I've got these 4 setting types:
  • String
  • Int
  • Double
  • Bool
I was wondering what other setting types I should work on adding. Please try to keep in mind that I'm not going to implement some incredibly complex setting type for 2 people to use. They need to make sense for everyone to use.
If you want to get ahold of me I'm almost always on Discord.
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

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

Post by Supercheese »

Is there an option for a "drop-down"? Sometimes I'd like to restrict possible selections to a list of items -- e.g. choose one of 4 voice styles in Red Alerts.

Something like: enumerating a list of valid strings for a String option changes it from a free textbox input to a drop-down. (Or perhaps assign a list of names to Ints rather than Strings; that seems to be how OpenTTD does it.)
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

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

Post by orzelek »

One thing I was thinking about is possibility to make group setting.
Something like:
Difficulty level: easy/med/hard/custom
And then have other settings change values based on this selection and switch it to custom if any of them are changed by hand.

It would help with allowing players to easily select set of settings if they don't want to dive into details while still allowing others to customise fully.
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

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

Post by Arch666Angel »

Allow for setting/option files to be outside of mods/zipped files. You may want to just exchange only the settings instead of The whole mod.
justarandomgeek
Filter Inserter
Filter Inserter
Posts: 302
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

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

Post by justarandomgeek »

Supercheese wrote:Is there an option for a "drop-down"? Sometimes I'd like to restrict possible selections to a list of items -- e.g. choose one of 4 voice styles in Red Alerts.

Something like: enumerating a list of valid strings for a String option changes it from a free textbox input to a drop-down. (Or perhaps assign a list of names to Ints rather than Strings; that seems to be how OpenTTD does it.)
+1 for dropdown selection over string/int datatypes, or just an enum type for picking from a list.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post by aubergine18 »

As others have said, some sort of enum setting for drop-downs would be superb. On-screen text would be localised enum keys.

Options could be defined as numeric array: { "opt1", "opt2", ... }

Default selection would be first item in array.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14338
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

I added support for dropdown (list of values) for the string and number settings.

I looked into adding support for a generic "select-prototype" option and I can do it with one caveat: I can't verify the settings in any way except when the end-user is selecting an option in the GUI. At startup or runtime all you'll get is a string.

My question is: is that still useful?
If you want to get ahold of me I'm almost always on Discord.
justarandomgeek
Filter Inserter
Filter Inserter
Posts: 302
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

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

Post by justarandomgeek »

Rseding91 wrote:I looked into adding support for a generic "select-prototype" option and I can do it with one caveat: I can't verify the settings in any way except when the end-user is selecting an option in the GUI. At startup or runtime all you'll get is a string.

My question is: is that still useful?
I think it would still be useful - the only time it would really go wrong is after mods change.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post by aubergine18 »

Rseding91 wrote:My question is: is that still useful?
Yes :)
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

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

Post by bobingabout »

Well, I'd personally only really use Double and Bool... MAYBE Int.

What I would like to see though, other than Up/Down buttons in the options GUI is basically... Definable Minimum and Maximum values, And a Step for when pressing the arrows, as well as a Default.


EG, you know it doesn't work below Zero, and above 10 causes issues, but you might want 0.05 steps, and a default value of 0.2 (Think module multiplier stats here)

These are just some of the things I think would make things easier.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

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

Post by Mooncat »

I wrote this in the FFF #177 thread but don't know whether Rseding have read that, so I repeat here:

I hope those mod settings that don't require game restart can go to the "Map generator" popup, inside a "Mod settings" tab. It will have better UX because all the similar things (settings) are grouped closely. :D
Rseding91
Factorio Staff
Factorio Staff
Posts: 14338
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Mooncat wrote:I wrote this in the FFF #177 thread but don't know whether Rseding have read that, so I repeat here:

I hope those mod settings that don't require game restart can go to the "Map generator" popup, inside a "Mod settings" tab. It will have better UX because all the similar things (settings) are grouped closely. :D
The only mod settings that require a restart are startup ones - ones that are used to alter prototypes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

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

Post by bobingabout »

Rseding91 wrote:
Mooncat wrote:I wrote this in the FFF #177 thread but don't know whether Rseding have read that, so I repeat here:

I hope those mod settings that don't require game restart can go to the "Map generator" popup, inside a "Mod settings" tab. It will have better UX because all the similar things (settings) are grouped closely. :D
The only mod settings that require a restart are startup ones - ones that are used to alter prototypes.
Which is currently ALL of mine.
Though I will be adding some in-game ones such as being able to turn off the GUI for my inserters mods.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

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

Post by Mooncat »

Rseding91 wrote:
Mooncat wrote:I wrote this in the FFF #177 thread but don't know whether Rseding have read that, so I repeat here:

I hope those mod settings that don't require game restart can go to the "Map generator" popup, inside a "Mod settings" tab. It will have better UX because all the similar things (settings) are grouped closely. :D
The only mod settings that require a restart are startup ones - ones that are used to alter prototypes.
I was talking about the other type of settings which affect how the functions in control.lua are executed. :P
I think RSO is a good example. It uses control.lua to alter map gen. Its settings are well fit in the map gen menu.

I have also thought about making suggestion to let us provide mod settings in the "Options" menu, so players can change them anytime, even in map. But then I think it will cause headache if different players in a multiplayer game have different settings. :lol:
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

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

Post by Arch666Angel »

Mooncat wrote:
Rseding91 wrote:
Mooncat wrote:I wrote this in the FFF #177 thread but don't know whether Rseding have read that, so I repeat here:

I hope those mod settings that don't require game restart can go to the "Map generator" popup, inside a "Mod settings" tab. It will have better UX because all the similar things (settings) are grouped closely. :D
The only mod settings that require a restart are startup ones - ones that are used to alter prototypes.
I was talking about the other type of settings which affect how the functions in control.lua are executed. :P
I think RSO is a good example. It uses control.lua to alter map gen. Its settings are well fit in the map gen menu.

I have also thought about making suggestion to let us provide mod settings in the "Options" menu, so players can change them anytime, even in map. But then I think it will cause headache if different players in a multiplayer game have different settings. :lol:
Adding options to the world gen menu is a good point btw, so you could a functions to change yield of infinites for example, or use different algorithms for shape, spread etc.
User avatar
ZlovreD
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 06, 2017 1:07 pm
Contact:

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

Post by ZlovreD »

And?..
Adding settings.json to the mod folder has no effect.
folk
Fast Inserter
Fast Inserter
Posts: 100
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

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

Post by folk »

EDIT: I've edited this post to contain some information from the posts below, because it is pinned at the factorio discord modding channel.
EDIT2: Rseding has now updated the main post at viewtopic.php?p=207275#p207275 with official documentation

So, I did this:

Code: Select all

folk@--:~/Programs/factorio/bin/x64$ strings factorio | grep settings
And got lots of stuff, including this:

Code: Select all

bool-setting
double-setting
int-setting
string-setting
...
settings.lua
settings-updates.lua
settings-final-fixes.lua
So it seems they added an entirely new pre-data stage, and I have confirmed it.
Here is snipped stdout, you can see the settings-stage is before data:

Code: Select all

   0.132 Create display on adapter 0. Size 1548x870 at position [176, 147].
   0.472 Initialised OpenGL:[0] GeForce GTX 680/PCIe/SSE2; driver: 4.5.0 NVIDIA 378.13
   0.473     Video memory size (dedicated/total available/current available): 2048/2048/1703 MB
   0.493 Graphics options: [Graphics quality: normal] [Video memory usage: high] [Light scale: 25%] [DXT: auto]
   0.618 Loading mod settings folk-fill 0.1.2 (settings.lua)
   0.620 Loading mod core 0.0.0 (data.lua)
   0.627 Loading mod base 0.15.1 (data.lua)
I added a file called settings.lua to my mod:

Code: Select all

data:extend({
	{
		type = "int-setting",
		name = "folk-fill-std-stack-size",
		setting_type = "runtime-per-user",
		default_value = 25,
		maximum_value = 100,
		minimum_value = -20,
		per_user = true,
	},
	{
		type = "bool-setting",
		name = "folk-fill-std-stack-test",
		setting_type = "runtime-per-user",
		default_value = true,
		per_user = true,
	},
	{
		type = "double-setting",
		name = "folk-fill-std-stack-test2",
		setting_type = "runtime-per-user",
		default_value = -23,
		per_user = true,
	},
	{
		type = "string-setting",
		name = "folk-fill-std-stack-test3",
		setting_type = "runtime-per-user",
		default_value = "Hello",
		allowed_values = {"Hello", "foo", "bar"},
		per_user = true,
	},
})
Valid setting types are "runtime-per-user", "runtime-global", and "startup".

The double-setting type crashes the game to desktop when you try to edit it ingame if the game can't parse what the player inputs as a number. (fixed next patch after 0.15.1)
The int-setting type does not crash like this.

To read these things in control.lua, it looks to me like:

Code: Select all

settings.get_player_settings(game.players[event.player_index])
Returns a table containing the settings as they were when you invoked it, here is the return through serpent.block:

Code: Select all

{
  nil,
  nil,
  nil,
  nil,
  ["folk-fill-std-stack-size"] = {
    value = 13
  } --[[table: 0x00007fd020003b50]],
  ["folk-fill-std-stack-test"] = {
    value = true
  } --[[table: 0x00007fd023dfbda0]],
  ["folk-fill-std-stack-test2"] = {
    value = -23
  } --[[table: 0x00007fd02000fa40]],
  ["folk-fill-std-stack-test3"] = {
    value = "what does the fox say"
  } --[[table: 0x00007fd02000def0]]
} --[[table: 0x00007fd0352b4a90]]
While, for the data stage, and defaults

Code: Select all

print(serpent.block(settings.player))
seems to yield the default settings:

Code: Select all

{
  nil,
  nil,
  nil,
  nil,
  ["folk-fill-std-stack-size"] = {
    value = 25
  } --[[table: 0x00007fd023df1700]],
  ["folk-fill-std-stack-test"] = {
    value = true
  } --[[table: 0x00007fd023def3e0]],
  ["folk-fill-std-stack-test2"] = {
    value = -23
  } --[[table: 0x00007fd0352908c0]],
  ["folk-fill-std-stack-test3"] = {
    value = "Hello"
  } --[[table: 0x00007fd023dba5a0]]
}
And don't forget http://lua-api.factorio.com/latest/even ... ng_changed

To get pretty locale strings for things, put this in your locale cfg

Code: Select all

[mod-setting-name]
folk-fill-std-stack-size= Stack size

[mod-setting-description]
folk-fill-std-stack-size=Default stack size to insert into placed entities inventories.\n\nNote: This is in percentage of default stack size. Setting this to 100 will insert a full stack, setting it to 25 will insert 1/4th of a stack.\n\nMinimum: 5% / Maximum 100%
Please note the extra space after the = in mod-setting-name, because the alignment of the UI elements in the mod options box are fubar. You should probably use two spaces, actually. This is also fixed first release after 0.15.1.

I've implemented two options for my mod https://mods.factorio.com/mods/folk/folk-fill if you need more code to look at.
Last edited by folk on Sat Apr 29, 2017 11:52 am, edited 4 times in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14338
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

I fixed the crash when editing the double setting type and fixed the label clipping issue for the next version of 0.15.

As for the per_user setting it makes it so each player in the game gets their own instance of the setting instead of their being 1 setting applied to everyone that only admins can change.

If you want a dropdown you use the "allowed_values" property to give it a list of values for the setting.
If you want to get ahold of me I'm almost always on Discord.
folk
Fast Inserter
Fast Inserter
Posts: 100
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

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

Post by folk »

I've implemented this in https://mods.factorio.com/mods/folk/folk-fill for anyone who wants to take a look. Although I believe my post above covers it as well.

@rseding91 thank you
Post Reply

Return to “Modding discussion”