I can't get Yanfly's option core to work correctly.

Narugami

Villager
Member
Joined
Mar 2, 2016
Messages
9
Reaction score
1
First Language
German
Primarily Uses
Plugins Used:
http://yanfly.moe/2015/10/09/yep-1-core-engine/
http://yanfly.moe/2018/04/13/yep-165-options-core-rpg-maker-mv/
http://yanfly.moe/2018/01/19/yep-162-advanced-switches-and-variables-rpg-maker-mv/

I'll try to explain my problem as best as I can. If I alter the default settings for any option of the plugin it doesn't work. Just as an example If I want the games sound to be at 80% by default after starting up the game for the first time, it is always 100% even if I put it like that.
Code:
//Default Config
ConfigManager[symbol] = 80;
Or another example I want to create an option that controls a switch so I make it like that.
Code:
//In the Options Pluign:
// Make Option:
this.addCommand(name, symbol, enabled, ext);

//Draw Option:
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var titleWidth = rect.width - statusWidth;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawOptionsName(index);
this.drawOptionsOnOff(index);

//Press OK:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
this.changeValue(symbol, !value);

//Crusor Right:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
this.changeValue(symbol, true);

//Crusor Left:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
this.changeValue(symbol, false);

//Default Config
ConfigManager[symbol] = true;

//Save Config
config[symbol] = ConfigManager[symbol];

//Load Cofing
ConfigManager[symbol] = !!config[symbol];
It works fine except for the default to be true. It's always off on default.
For the Switch that should be controlled by this, I use this:
Code:
Eval: ConfigManager['exampleoption']
So my issue with this is that I can't set first time startup defaults for the yanfly options core plugin. Does anyone have an idea what is wrong with this? I already tried to make a new project with only these three plugins and got the same result.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
If you change the Load Config code to this, does it work?
Code:
if (config[symbol] !== undefined) ConfigManager[symbol] = !!config[symbol];
 

Narugami

Villager
Member
Joined
Mar 2, 2016
Messages
9
Reaction score
1
First Language
German
Primarily Uses
If you change the Load Config code to this, does it work?
Code:
if (config[symbol] !== undefined) ConfigManager[symbol] = !!config[symbol];
Yes this works out great! Thanks! But why?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
Yes this works out great! Thanks! But why?
Yay! :kaojoy:

I think it's because the default value is applied first, then it loads the value from the file. If that value isn't already in the saved options, config[symbol] will be undefined. Unfortunately undefined is falsy so the !! ("not-not") converts that to false, overriding the default true value.

In short: "skip this if this option wasn't found in the saved settings". :kaoswt:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top