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

Place to post guides, observations, things related to modding that are not mods themselves.
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 »

Settings load BEFORE the data stage... which makes sense when you consider that the data stage can make use of settings.

therefore, settings can't read from the data.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

Rseding91 wrote:No, the nature of settings means they can't have access to the data stage otherwise they wouldn't be deterministic in multiplayer.
bobingabout wrote:Settings load BEFORE the data stage... which makes sense when you consider that the data stage can make use of settings.

therefore, settings can't read from the data.
All players have same data.raw table. So, I can't understand, why it can make desyncs?

Working example, I read belts speed of all belts in data.raw, then make this parameters as default values for mod settings.

If I change some of them, the game will be restarted and new values have higher priority then defaults, that was added before.

All players, that join this game, get mod settings file, restart the game and the game has the same state as server. No desyncs possible.

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

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

Post by Rseding91 »

darkfrei wrote:
Rseding91 wrote:No, the nature of settings means they can't have access to the data stage otherwise they wouldn't be deterministic in multiplayer.
bobingabout wrote:Settings load BEFORE the data stage... which makes sense when you consider that the data stage can make use of settings.

therefore, settings can't read from the data.
All players have same data.raw table. So, I can't understand, why it can make desyncs?

Working example, I read belts speed of all belts in data.raw, then make this parameters as default values for mod settings.

If I change some of them, the game will be restarted and new values have higher priority then defaults, that was added before.

All players, that join this game, get mod settings file, restart the game and the game has the same state as server. No desyncs possible.
  • Mod setting 1 value = #inserters
  • In data.raw create # of special inserters using Mod setting 1 value
Every time you restart the game the number of inserters increases because it uses the value it had from the last restart to make the new value.
If you want to get ahold of me I'm almost always on Discord.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

Rseding91 wrote:
  • Mod setting 1 value = #inserters
  • In data.raw create # of special inserters using Mod setting 1 value
Every time you restart the game the number of inserters increases because it uses the value it had from the last restart to make the new value.
You are right. But can I have a very big table of entities of all mods with (like it was in example) modded belts, but hide mod settings, when this mods are not installed?

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 »

I see localised drop down strings were added, thanks!

The syntax is:

Code: Select all

[string-mod-setting]
<mod-name>-<setting-name>-<dropdown-item-name>=<translated item>
Let's say you have an hello mod, with the following setting declared in settings.lua:

Code: Select all

{
    type = "string-setting",
    name = "hello-foobar",
    setting_type = "runtime-per-user",
    default_value = "first-choice",
    allowed_values = {
        "first-choice",
        "second-choice",
    },
    order = "a",
},

Since all mod setting names share a single namespace, it's a common good practice to prefix every setting name with the mod name (hello-foobar).
But the dropdown localised string requires prefixing it again, which leads to double prefixes:

Code: Select all

; en.cfg
[mod-setting-name]
hello-foobar=Choose

[string-mod-setting]
hello-hello-foobar-first-choice=First choice
hello-hello-foobar-second-choice=Second choice
I'm all for proper namespacing, but it should be consistent (either remove it from string-mod-setting or add it to all other sections like mod-setting-name)!

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

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

Post by Rseding91 »

I'm going to change it so it doesn't use the mod-name as a prefix and just uses the setting name.

Since as you've said: it makes sense to already prefix your setting names (and they're all unique anyway).
If you want to get ahold of me I'm almost always on Discord.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

Rseding91 wrote:I'm going to change it so it doesn't use the mod-name as a prefix and just uses the setting name.

Since as you've said: it makes sense to already prefix your setting names (and they're all unique anyway).
Is it possible don't write mod name by file path?
So, instead of

Code: Select all

icon = "__HydraulicPumpjacks__/graphics/icon-deep-crude-oil.png"
can be written just

Code: Select all

icon = "__/graphics/icon-deep-crude-oil.png"
or something same. So, copying code and graphics from one mod to another don't need any code replacing.

dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 07, 2017 8:50 pm
Contact:

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

Post by dewiniaid »

darkfrei wrote:
Rseding91 wrote:
  • Mod setting 1 value = #inserters
  • In data.raw create # of special inserters using Mod setting 1 value
Every time you restart the game the number of inserters increases because it uses the value it had from the last restart to make the new value.
You are right. But can I have a very big table of entities of all mods with (like it was in example) modded belts, but hide mod settings, when this mods are not installed?
Month-old post, but you can sort of accomplish this another way. The settings pass has access to a list of installed mods. QuickItemSwap uses this to show options for integrating with Creative Mode only if the latter is installed.

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:
Supercheese wrote:Oh, so there is an "order" property that can be set? It's impossible to know such things without documentation...
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 :P
Speaking as someone who has been modding factorio off and on for maybe three years... I still have no idea how the order property works or what the variosy syntax inside of it does. I just copy the order property of something similar to what I'm working on and tweak it and hope for the best.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
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:
Supercheese wrote:Oh, so there is an "order" property that can be set? It's impossible to know such things without documentation...
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 :P
Speaking as someone who has been modding factorio off and on for maybe three years... I still have no idea how the order property works or what the variosy syntax inside of it does. I just copy the order property of something similar to what I'm working on and tweak it and hope for the best.
https://wiki.factorio.com/Types/Order
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 »

A) Thanks, glad to see the wiki getting more informative!

B) So I've been wasting my time trying to understand what all the pieces of order strings like "b[decorative]-k[stone-rock]-c[crystal]" mean? It's really just a straight lex ordering, with no special meaning for [] or -?

C) Is it case sensitive???

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

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

Post by Rseding91 »

sparr wrote:A) Thanks, glad to see the wiki getting more informative!

B) So I've been wasting my time trying to understand what all the pieces of order strings like "b[decorative]-k[stone-rock]-c[crystal]" mean? It's really just a straight lex ordering, with no special meaning for [] or -?

C) Is it case sensitive???
B and C: yes.
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 »

is the lexical ordering ASCII? so 0 < A < Z < _ < a < z < ~

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

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

Post by Rseding91 »

sparr wrote:is the lexical ordering ASCII? so 0 < A < Z < _ < a < z < ~
yes
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 »

ok, just so I make sure I and future readers understand...

"a[foo]-b" will sort AFTER "a[fooX]-c" because X<]

This seems to contradict what many mod authors expect, based on hundreds of examples I looked at across dozens of mods while trying to figure out how this field worked on my own. I'm glad it's on the wiki now, but there's a lot of cultural inertia here that needs fighting, as people learn by looking at other people's work.

and/or the order field needs more useful/intuitive sorting functionality.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post by eradicator »

sparr wrote:ok, just so I make sure I and future readers understand...

"a[foo]-b" will sort AFTER "a[fooX]-c" because X<]

This seems to contradict what many mod authors expect, based on hundreds of examples I looked at across dozens of mods while trying to figure out how this field worked on my own. I'm glad it's on the wiki now, but there's a lot of cultural inertia here that needs fighting, as people learn by looking at other people's work.

and/or the order field needs more useful/intuitive sorting functionality.
Ugh. Could've sworn i read somewhere that the '[blah]-' bit is ignored for sorting purposes and was just used as a comment to make the string easier to understand >_>. Including the bracket content in the search order is... unintuitive at best, to use a nice word.

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 »

eradicator wrote: Ugh. Could've sworn i read somewhere that the '[blah]-' bit is ignored for sorting purposes and was just used as a comment to make the string easier to understand >_>. Including the bracket content in the search order is... unintuitive at best, to use a nice word.
My understanding is that most (all?) of the time, the bracketed name is ignored because the letter that comes before is always different (in a given group). So the bracketed name acts as a description of the letter that comes before it

Example :
a[science-pack-1]
b[science-pack-2]
c[science-pack-3]
d[military-science-pack]
e[production-science-pack]
f[high-tech-science-pack]
g[space-science-pack]

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 »

mickael9 wrote:My understanding is that most (all?) of the time, the bracketed name is ignored because the letter that comes before is always different (in a given group). So the bracketed name acts as a description of the letter that comes before it

Example :
a[science-pack-1]
b[science-pack-2]
c[science-pack-3]
d[military-science-pack]
e[production-science-pack]
f[high-tech-science-pack]
g[space-science-pack]
Within the base mod, this is [almost?] entirely true. But other mods can use the same letter with a different bracketed string.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post by eradicator »

sparr wrote:
mickael9 wrote:My understanding is that most (all?) of the time, the bracketed name is ignored because the letter that comes before is always different (in a given group). So the bracketed name acts as a description of the letter that comes before it

Example :
a[science-pack-1]
b[science-pack-2]
c[science-pack-3]
d[military-science-pack]
e[production-science-pack]
f[high-tech-science-pack]
g[space-science-pack]
Within the base mod, this is [almost?] entirely true. But other mods can use the same letter with a different bracketed string.
That's not "being ignored" though, that's "happens to have no visible effect". The problem is i always assumed something like this:

BaseItemOne.order = 'a[Superstuff]-c[Awesomeplate]'
ModItemSeven.order = 'a-b'

and thought that that would lead to the mod item being sorted before the base item. Which it does not according to what was explained here.

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 »

I think this should be stickied again.

I wanted to add a new mod setting to one of my mods, using a type I'd not used before, and as a good programmer, I wanted to look it up rather than just guessing.
I couldn't find the information on the Wiki, or in the lua-api, and I knew this data was here. But that was before the recent replies, and had to dig through this subforum to find the topic.

I get why it was unstickied, the title is a question, and the question is over, but the first page was re-written to give you ALL the required information, which is useful.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding discussion”