Is there a way to read personalized settings during the Prototype stage?

Place to get help with not working mods / modding interface.
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

Hello,
I'm currently working on a anti-phobia mod and it needs to replace sprites with ones less triggering in order to work. However, people who don't have that phobia don't necessarily need the swapped out sprites and so I wanted to have a setting to try to keep them vanilla if possible. Is there any way of actually doing this? I currently cannot think of any way of handling this at the moment as personal settings are only accessible during the control stage of the game.

Any help is appreciated!
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 546
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Silari »

Only startup settings can be used in the data stage. Allowing per-player settings would definitely lead to desyncs.

Far as I'm aware none of the actual graphics are game state, so the game won't care if they don't match between clients (though the files need to be similar enough that they work with the exact same prototype settings) but that's not anything you can do within the modding system. You could do it by abusing the system outside of the game and have people swap in/out graphics files physically, but that would be a real pain in the butt for the end users.
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

Yeah. I was afraid that was going to be the case. I was really hoping to avoid the file swap. I know some older mods used to have their own settings files, but I don't think that's supported any more either.
Natha
Fast Inserter
Fast Inserter
Posts: 229
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Natha »

Pikachar wrote: Mon Dec 09, 2024 5:51 pm Yeah. I was afraid that was going to be the case. I was really hoping to avoid the file swap. I know some older mods used to have their own settings files, but I don't think that's supported any more either.
You can still build your own settings file, but it won't be in the settings GUI then.
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

What's the proper way to do that then? Or is there some sort of guide for how to do that you can link me to? As far as I can tell, the Lua io library is not included here, so using that seems out of the question. But, yeah, if you could point me toward how to properly do that, I'd appreciate it.
Natha
Fast Inserter
Fast Inserter
Posts: 229
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Natha »

just include a config.lua, which looks like that:

setting_name1 = settings_value1
setting_name2 = setting_value2

these variables are global. The file is still a norma lua code file
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

This is useful information. However, I was hoping for some sort of external persistence. ie, still be able to save something from the game into an external settings/config file and read it on game start or something.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 840
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by IsaacOscar »

Pikachar wrote: Fri Dec 13, 2024 4:29 am This is useful information. However, I was hoping for some sort of external persistence. ie, still be able to save something from the game into an external settings/config file and read it on game start or something.
I'm pretty sure you can only load files from the mod directory, and there's no way to write to files there (you can write to the factorio log file, but that won't help you).

If you're happy to require your uses do a bit of work to install your mod, you could cheat by using this function https://lua-api.factorio.com/latest/cla ... write_file and make symlink from your mods folder to a lua file in script_output (making symlinks on Windows however requires admin rights for some reason)
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

I take it there's no good way to read something from the script-output folder without a simlink then? Because the goal is to minimize the digging/editing of files that the user has to do.

Because, I'm thinking of doing something along the lines of:
1. Create a user setting
2. Check this event: 'on_runtime_mod_setting_changed' for my setting
3. Write out setting to some 'config.lua' file
4. On game start, read the setting in the 'config.lua' file.

At this point, step 4 seems to be the tricky part. Can the game not require or read files somehow from the script-output folder without using a simlink?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3393
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by boskid »

Answering the original question: it is not possible to have player specific settings affect data stage. We do our best to disallow that and if you find a way then it is going to be removed because it would be a bug. Architecture of multiplayer heavily relies on all clients and server to agree on the content of all the prototypes because they affect outcome of simulation update. If there would be a difference in prototypes, client would desync from the server. Shared settings are allowed because on join, client must have them equal to server settings.

There are some pieces of data not affecting game state (locale, sprites, sounds, hr settings) but the data produced by data stage lua must be equal.
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by Pikachar »

Well, as disappointing as that is, I thank you all for the responses. This has at the very least, been a learning experience.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 840
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: Is there a way to read personalized settings during the Prototype stage?

Post by IsaacOscar »

Perhaps it's worth submitting a modding interface request for another stage between data and runtime, that is allowed to read per user settings but only write non-gameplay prototype data?

Although that would probably be a lot of work for Wube and lead to many desync bugs.
Post Reply

Return to “Modding help”