Page 1 of 1
Dependency between mod settings
Posted: Sat Apr 06, 2019 6:38 pm
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?
Re: Dependency between mod settings
Posted: Sat Apr 06, 2019 6:57 pm
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.
Re: Dependency between mod settings
Posted: Sat Apr 06, 2019 7:05 pm
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

Re: Dependency between mod settings
Posted: Sat Apr 06, 2019 7:07 pm
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 }
Re: Dependency between mod settings
Posted: Sat Apr 06, 2019 7:09 pm
by jarcionek
Nice! Thanks a lot!
Re: Dependency between mod settings
Posted: Mon Apr 08, 2019 11:54 am
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?
Re: Dependency between mod settings
Posted: Mon Apr 08, 2019 12:02 pm
by eduran
0.17.0, it's in the scripting section of the changelog.
Re: Dependency between mod settings
Posted: Mon Apr 08, 2019 12:53 pm
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
Re: Dependency between mod settings
Posted: Mon Apr 08, 2019 1:13 pm
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
