Dependency between mod settings

Place to get help with not working mods / modding interface.
jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

Dependency between mod settings

Post by jarcionek »

I have two numbers in my mod settings, one should be greater than the other - is it possible to set its minimum value to the value of the other one?

Alternatively, this is a runtime-per-player setting so I could check it in on_configuration_changed action and set it to a different value, however all the data I can see is read only. Is it possible to change player's mod setting with a script?
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Dependency between mod settings

Post by eduran »

No to both of your questions. The best you can do is use a different value internally. Maybe print a warning message when you do so and/or explain in the setting tooltip.

Edit: My initial answer was wrong, in 0.17 it is possible to change mod settings (see below). Changing the limit is still impossible, as it is set at the data stage.
Last edited by eduran on Sat Apr 06, 2019 7:08 pm, edited 1 time in total.
jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

Re: Dependency between mod settings

Post by jarcionek »

Thanks. I was already thinking that I can print a message to the player, but the idea of using different value internally is great. I will have to do some code refactoring, because currently I have calls to player.mod_settings all over the place :)
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Dependency between mod settings

Post by eduran »

Actually, I was wrong. Apparently 0.17 added a way for mods to change their settings:

Code: Select all

settings.get_player_settings(player_index)[setting_name] = { value = new_value }
jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

Re: Dependency between mod settings

Post by jarcionek »

Nice! Thanks a lot!
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Dependency between mod settings

Post by bobingabout »

eduran wrote: Sat Apr 06, 2019 7:07 pm Actually, I was wrong. Apparently 0.17 added a way for mods to change their settings:

Code: Select all

settings.get_player_settings(player_index)[setting_name] = { value = new_value }
I heard they were going to add this, but didn't see anything about it in the changelogs

does anyone know what version this was done in?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Dependency between mod settings

Post by eduran »

0.17.0, it's in the scripting section of the changelog.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Dependency between mod settings

Post by bobingabout »

eduran wrote: Mon Apr 08, 2019 12:02 pm 0.17.0, it's in the scripting section of the changelog.
thanks
seems a bit of an odd way to do it though. why not do this?

Code: Select all

settings.get_player_settings(player_index)[setting_name].value = new_value
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Dependency between mod settings

Post by eduran »

That was my first idea, too. I could not make it work that way. So I posted the version that does work.
Probably just a stupid mistake in my test code :oops:
Post Reply

Return to “Modding help”