How to save custom options?

topic.
It probably has something to do with this:
Code:
ConfigManager.makeData = function() {
    var config = {};
    config.alwaysDash = this.alwaysDash;
    config.commandRemember = this.commandRemember;
    config.bgmVolume = this.bgmVolume;
    config.bgsVolume = this.bgsVolume;
    config.meVolume = this.meVolume;
    config.seVolume = this.seVolume;
    return config;
};

ConfigManager.applyData = function(config) {
    this.alwaysDash = this.readFlag(config, 'alwaysDash');
    this.commandRemember = this.readFlag(config, 'commandRemember');
    this.bgmVolume = this.readVolume(config, 'bgmVolume');
    this.bgsVolume = this.readVolume(config, 'bgsVolume');
    this.meVolume = this.readVolume(config, 'meVolume');
    this.seVolume = this.readVolume(config, 'seVolume');
};
Yes, that seems correct to me. What is your question exactly? You will need to alias both these functions to add your custom option to the config object and to read it upon loading.

You seem to have enough coding knowledge to find these functions, so I would appreciate a more detailed question with what exactly you need assistence.
I am using Yanfly Options core and I added an option with "cursor right code":

Graphics._requestFullScreen();

The problem is, when the player starts the game, this option is not applied.
So I am running a common event on launch that checks a gameswitch. If the switch is on, the common event does "Graphics._requestFullScreen();" and the game launches in fullscreen. I added to turn the switch on in the "cursor right code", BUT since the switches are saved with the gamesave-file, it does not work when the player accesses the option BEFORE launching a new game or loading an old game.

fullscreen option.png



I don't want to use the global switches plugin from Olivia, it is too inconsistent for me.

I guess a Plugin that adds stuff to the "ConfigManager.makeData = function() {" and the "ConfigManager.applyData = function(config) {" would be the best way to solve this problem. But I don't know how the game handles this option-loading stuff exactly.
I guess a Plugin that adds stuff to the "ConfigManager.makeData = function() {" and the "ConfigManager.applyData = function(config) {" would be the best way to solve this problem.
Well lucky for you, Yanfly's Options Core already seems to provide that ... option. Simply insert the following code after the default code into the Load Config Code parameter of your custom option:
JavaScript:
if(ConfigManager[symbol]) Graphics._requestFullScreen();

As an aside, the next time you ask for help with anything please do mention that you are using a plugin that completely alters how the aspect you are asking about functions and please do describe what actually is not working. Because if I look at the plugin the value you set to your option called "fullscreen" should be saved and loaded just fine - only the function call to actually enter fullscreen mode would not have been executed.
JavaScript:
if(ConfigManager[symbol]) Graphics._requestFullScreen();
It doesn't do anything. I also tried :
JavaScript:
if(ConfigManager[symbol]) {
 Graphics._requestFullScreen();
}
It also doesn't do anything if i put it in the common event script that runs on game launch.
Maybe it should look something like this?:
JavaScript:
if (ConfigManager[symbol] === 'AN') {
 Graphics._requestFullScreen();
}

I will look into the yanfly BattleAniSpeedOption plugin and look there how it recognizes the option setting. Edit: I am not able to understand what it does exactly.
push
JavaScript:
Code:
if(ConfigManager[symbol]) {
 Graphics._requestFullScreen();
}
This is the same code that I proposed. If you only have one statement following the if(...) you can leave out the curly brackets.
JavaScript:
Code:
if (ConfigManager[symbol] === 'AN') {
 Graphics._requestFullScreen();
}
This will not work as ConfigManager[symbol] is a boolean value (either true or false).

I just verified that my proposed method does work. So let's start with the standard troubleshooting:
- can you please share screenshots of how you configured this option in the plugin parameters?
- have you checked that your Yanfly plugins are in the correct order?
- have you checked that this method also doesn't work in a clean new test project?

You can also see what the value of ConfigManager[symbol] is by adding:
JavaScript:
console.log(ConfigManager[symbol]);
And then open the console by pressing F8.
I just verified that my proposed method does work.
It actually does work now. In Yanfly_optionsCore, in my fullscreen setting, I inserted "\i[55]" as the Symbol. But the Symbol section is not supposed to use icons. I entered the string "fullscreen" into the Symbol section and that fixed it! I am actually able to load other options now, too!

Thx a lot @eomereolsson! I will add you to my credits for troubleshooting! 🙂
Yes, "symbol" has nothing to do with any graphical icons that get displayed but rather means the unique identifier for that option.

Glad to hear it is working now 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-save-custom-options.150268/