Page 3 of 11

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

Posted: Mon Dec 26, 2016 4:35 am
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.

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

Posted: Mon Dec 26, 2016 7:13 am
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.)

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

Posted: Tue Dec 27, 2016 2:15 am
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.

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

Posted: Tue Dec 27, 2016 1:31 pm
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.

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

Posted: Tue Dec 27, 2016 5:11 pm
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.

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

Posted: Wed Dec 28, 2016 8:22 pm
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.

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

Posted: Sun Jan 29, 2017 2:59 pm
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?

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

Posted: Sun Jan 29, 2017 6:36 pm
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.

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

Posted: Wed Feb 01, 2017 4:20 pm
by aubergine18
Rseding91 wrote:My question is: is that still useful?
Yes :)

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

Posted: Thu Feb 23, 2017 2:59 pm
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.

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

Posted: Thu Feb 23, 2017 4:52 pm
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

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

Posted: Thu Feb 23, 2017 8:03 pm
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.

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

Posted: Fri Feb 24, 2017 9:16 am
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.

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

Posted: Wed Mar 01, 2017 2:08 am
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:

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

Posted: Wed Mar 01, 2017 7:08 am
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.

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

Posted: Mon Apr 24, 2017 9:12 pm
by ZlovreD
And?..
Adding settings.json to the mod folder has no effect.

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

Posted: Tue Apr 25, 2017 4:56 am
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.

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

Posted: Tue Apr 25, 2017 6:01 am
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.

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

Posted: Tue Apr 25, 2017 6:38 am
by Supercheese
Thanks guys, this will be of much help.

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

Posted: Tue Apr 25, 2017 7:24 am
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