- Nov 22, 2020
- 221
- 62
Mod Support Devlog 2: Creating Game Settings
Trying to post devlogs more frequently, I wanted to continue the last devlog about scripts, like I said, I have been refactoring the mod's code to allow other mods to interact with the systems easier. This one won't be as long as the first one tho.
As for this devlog, I have been working on modifying the mod's game settings module to allow any installed mod to create custom game settings and categories (a settings page) on the game's without too much hassle. Thankfully I had a solid foundation to work on due to the last modification I did for the game settings in a previous devlog.
All settings must be created using a script, this can't be done in another way, taking advantage of the initialization event the sana revamped sends you can make your mod create any number of settings and add them to the mod's settings module right after the game launches.
There are also some other changes I have made to the original Settings menu I shared some time ago, I have modified the script to allow to change the value of any slider setting in increments/decrements of 10 if SHIFT is pressed while changing the value, this is something that was needed, especially for sliders that allow large number ranges.
Here's an example of a settings page, I have created two mods, each of them creates a page on the settings menu with their own settings:
You can interact with the settings menu with the confirm key ('Z') that cycles through all possible values, left and right arrow keys to change to the prior and next value.
The supported type of settings are:
Allows the user to select a string value from a fixed list of values ("English", "Spanish", "German", etc...)
List Setting
Allows to select a number value from a fixed range of numbers (-100..100, 0..10, 0..100, 0..1000, etc...)
Slider Setting
Acts as a toggle, basically ON/OFF => true/false
Switch Setting
However, there is one drawback, and that is that the code to create a page within the game settings menu is quite long and verbose.
As an example, here's the code that creates the settings page for the "Side Stories" mod that appears on the menu:
You don't have permission to view the spoiler content. Log in or register now.
Each setting needs to set a few handlers so it can work properly, I have created some default handlers, but you can also set it to your custom ones if desired.
Moving on, the settings menu is now able to reset a setting default value by pressing 'R' on the current highlighted setting, as you can see in this gif all settings are reset to the default value in different pages (whether they are created by a mod or by the game itself)
Like I said, I'm trying my best so the mods don't need to save data into save files, to avoid the possibility of the files becoming corrupted, that's why I have done this so mods can save any setting in a external file easily without modifying save files.
Here's is a piece of contents of the JSON file generated with all settings:
Also, I have changed how the settings are saved and loaded to avoid deleting setting IDs that may not exist in the game, which means that you will be able to add and remove mods and their settings won't be deleted from the JSON file, it will persist inside of it, in case the mod is installed again in the future, it will be able to load the old settings back without problems (as long as their IDs has not changed)JSON:{ "sr_dev_console_enabled": true, "sr_dev_logging_enabled": true, "sr_language_id": "english", "sr_audio_master_volume": 32, "jd_first_mod_enabled": true, "jd_first_mod_extra_content": true, "jane_doe_side_stories_mod_enabled": true, "jane_doe_side_stories_on_off_value": true, "jane_doe_side_stories_list_value": "Hard", "jane_doe_side_stories_slider_value": 8 }
Just in case, I also added a function to the Settings module to perform a cleanup on the JSON file to delete settings that does not exist currently, just in case anyone wants to clean their JSON file.
I'm currently making the same changes to the In-Game console module so any mod can create and add their own commands to debug the game, but it's not currently finished so I will talk about this in the next devlog!
My god this is pure gold, if I had any programming knowledge I would be trying to increase the content, this is one of my favorite h games.
(English is not my mother tongue)
Thank you very much for your work