Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Place to get help with not working mods / modding interface.
Post Reply
Tynach
Inserter
Inserter
Posts: 31
Joined: Sun Aug 21, 2016 9:22 pm
Contact:

Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by Tynach »

I have a mod that just replaces the color LUTs for night (and adds a LUT for sunrise/sunset, and replaces the night vision LUT). This doesn't change the game in any way, but it does change the visibility at night - and because not everyone's monitor is going to be the same, I'm wanting to add multiple variations of the LUTs and let the user decide which to use.

However, if I'm reading the mod settings API documentation correctly, only 'startup' settings can be read by the 'data*.lua' scripts... Which are where I have it changing things like the 'data.raw\["utility-constants"\]\["default"\].daytime_color_lookup' value. At the same time, the documentation states that all users of a multiplayer server must have such settings set to the same value.

This is a problem, because the whole point of the setting is that everyone's display is likely to require a different setting. Since the mod does not affect gameplay in any way a server needs to know about, but 'runtime-per-user' is stated to not be readable by 'data*.lua' scripts, I was hoping maybe there was an undocumented 'startup-per-user' setting type, or if perhaps I'm wrong about what the documentation says about the various types (I might simply be reading it wrong, after all).

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by posila »

There no way to do this in 0.18 and 1.0 for that matter.

Your only hope is to add color filter matrix to utility-constants, and than player can select it in graphics settings. However, the matrix is applied to final composition, so it affects also GUI.

Tynach
Inserter
Inserter
Posts: 31
Joined: Sun Aug 21, 2016 9:22 pm
Contact:

Re: Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by Tynach »

posila wrote:
Tue Jul 28, 2020 8:47 am
There no way to do this in 0.18 and 1.0 for that matter.

Your only hope is to add color filter matrix to utility-constants, and than player can select it in graphics settings. However, the matrix is applied to final composition, so it affects also GUI.
I'd be all for a color matrix being used, except that wouldn't help with the appearance of colors specifically at night - it would apply globally to all colors, during the day and otherwise. I also would not be in control of gamma correction (if any), which is the whole point of me adding an option - some monitors use sRGB, others use a simpler 2.2 gamma curve. But the two differ most in the darker ranges, which means night time is especially affected.

Color matrices, as powerful as they may be, cannot control how gamma correction is applied.. But LUTs can, which was one reason why I backed down from criticizing LUTs when I first reacted to the color correction post (FFF 320). I now applaud the use of LUTs, though I wish I could dynamically load them after startup.

... Actually, that should be a thing I'm asking. Is it possible to choose which LUTs are loaded after startup, during runtime? I had assumed not, based on at least two of the prototypes being loaded in 'utility-constants.lua'; the name included 'constants', so I assumed they could not be changed at runtime.

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by Hiladdar »

There might be a way, but it would require quite a bit of coding, and it will work for single player, but might create some issues in the multi-player. If your are writing your mod only for single player, than consider this.

Setting.lua can configure values and store those values with save file. I use that technique in some of my mods, to allow players to configure some values for some entities, and adjust other values of entities based on the player's choose. In this case you would could have the player make their selection, and in the settings, and then the players' choice and use it either as a variable.

For multiplayer this becomes much more difficult, and this technique will not work. If this same technique is used, it will affect every client using that game. It is possible to get around that, but the fix is to have some sort of configuration file stored on each of the client boxes. Your lua code would have to pull the information either from Factorio, or a binary. The issue there is you have no way of knowing of what operating system and what version of the operating system, the Factorio is running on. From Lua, it is possible to call C and C++ functions, provided they were issued part of the include statement. That documentation is located in the lua language documentation (https://www.lua.org/docs.html). Beyond that, you would need to create something like an API function, to provide a bridge, between lua and the operating system you are playing, with it's own set up file to store that setup. It might be possible, but the amount of work required probably would not be practice for a mod developers.

I do think what you are trying to do is very worthwhile, and based on Posila's comment, and my understanging of your intent, this might make for a great recommendation for implementation into the core game as an additional graphics option to select. If this is to be a request for the core game, it should probably be an option on the Graphics Settings for the core game.

Hiladdar

Tynach
Inserter
Inserter
Posts: 31
Joined: Sun Aug 21, 2016 9:22 pm
Contact:

Re: Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by Tynach »

Hiladdar wrote:
Wed Jul 29, 2020 5:01 pm
There might be a way, but it would require quite a bit of coding, and it will work for single player, but might create some issues in the multi-player. If your are writing your mod only for single player, than consider this.
The point of my concern is purely with regards to multiplayer. If I'm targeting single player only, I'd just use 'startup' settings and be done with it.. But I want people to be able to have the mod installed and enabled, and not have to worry about what their friends have their settings set to, or even if everyone has the mod or not. Multiplayer should be completely unaware the mod exists, ideally.

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: Is there a way to make a global 'startup' setting, that DOESN'T sync with servers in any way?

Post by Hiladdar »

Tynach wrote:
Thu Jul 30, 2020 5:47 am
Hiladdar wrote:
Wed Jul 29, 2020 5:01 pm
There might be a way, but it would require quite a bit of coding, and it will work for single player, but might create some issues in the multi-player. If your are writing your mod only for single player, than consider this.
The point of my concern is purely with regards to multiplayer. If I'm targeting single player only, I'd just use 'startup' settings and be done with it.. But I want people to be able to have the mod installed and enabled, and not have to worry about what their friends have their settings set to, or even if everyone has the mod or not. Multiplayer should be completely unaware the mod exists, ideally.
I agree with you, on the transparency of the mod. I like what you are trying to accomplish. I think that the best place for this functionality is to be incorporated into the base code.

Hiladdar

Post Reply

Return to “Modding help”