RMMV Toggle Switch in Option menu using YEP_OptionsCore.js

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
So I'm trying to put an option in the options menu using Yanfly's Option Core plugin. Since I pretty much want what this guy here wanted, I read his thread and applied the same things:

https://forums.rpgmakerweb.com/inde...m-options-in-the-options-menu-yep-165.103087/

Unfortunately that discussion is now locked so I have to make my own topic asking for more or less the same thing. Or rather asking for help in finding the one thing that doesn't work. Because it mostly does.

What doesn't work is that sometimes when I toggle a switch ON/OFF outside of the menu and go back into the menu to toggle it fro there, it doesn'r register at first. I have to press three times before it registers the change. I assume this is because it won't draw the first change (but will actually toggle the switch), then when I press again it will both toggle the switch and draw the change but since that means that it's the same as it was before I started toggling the switch inside the options menu, it looks like nothing has changed. Then when I press a third time it toggles and draws the change as it's supposed to.

It doesn't matter if I start from ON or OFF. As soon as I toggle it outside of the menu, I have to press three times inside the menu before it shows the changes properly again.

Here's what I've put in the plugin parameters (I'm still using Switch 12 but I plan to change that to Switch 1 later).

Code:
this.addCommand(name, symbol, enabled, ext);

Code:
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var titleWidth = rect.width - statusWidth;
var halfStatusWidth = this.statusWidth() / 2;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawOptionsName(index);
var value = $gameSwitches.value(12);
this.changePaintOpacity(!value);
this.drawText("off text", titleWidth, rect.y, halfStatusWidth, 'center');
this.changePaintOpacity(value);
this.drawText("on text", titleWidth + halfStatusWidth, rect.y, halfStatusWidth,'center');

Code:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = $gameSwitches.value(12);

$gameSwitches.setValue(12, !value);
this.changeValue(symbol, !value);

Code:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = $gameSwitches.value(12);

$gameSwitches.setValue(12, true);
this.changeValue(symbol, true);

Code:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = $gameSwitches.value(12);

$gameSwitches.setValue(12, false);
this.changeValue(symbol, false);

Code:
ConfigManager[symbol] = false;

Code:
config[symbol] = ConfigManager[symbol];

Code:
ConfigManager[symbol] = !!config[symbol];


It does work in general...except the problem I mentioned above so it would be fantastic if someone could help me find that little bug that must be hiding somewhere in the above copy-pasted code.

It would be very much appreciated.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
did you watch this video? this explain how to use switches effecively, or how to add
them easier in the way you want, it require however a 2nd plugin, if you dont mind that.

video can be found here, can be found on the forum as well.
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
Thanks for the link. I went through that tutorial and it works okay, but it has the same problem. If I use an event to toggle this switch OUTSIDE of the menu, the setting inside the menu will not change and become unsynced.

This probably works if there's a setting you only have in the options menu but I plan to show a choice at the start of a new game where the player can pick if they want this option to be "ON" or "OFF" and by doing that they may unsync the settings.

What I need is some code snippet that updates the menu option the the switches current setting. I can only assume that this would be something I'd have to place in the "Draw Option Code" parameter but I don't know what I ought to type.

Any ideas?
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
It might work if you have olivia's meta plugn to check for global instead of the other thing.
and only on save files existed.

if you use 8 difference, that require 8 choices of yes/no or otherwise.
but if it need to be sync from title to the game, I thin you need to modify the title scene
options carry over into the game save slot or something like that.
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
I'm actually using Olivia's meta variable/switch plugin. And it does work as it should under the hood. The problem is that inside the menu when the option is drawn, it's not drawn properly because it's not checking the actual state of the switch. I'm confident this must be where the problem is but I can't fix it since I can't write JS myself...
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
I learn it a little, but while switches mostly work INSIDE the game, it's not drawn from title.
I dont know if there is a possibility for it though.

Title MAP (skip main title) might work, but on the otherside, it does not while it resets
switches to 0 (OFF), the only thing I can think off, if possible,if a persistend SWITCH
that when ON, from title, the switch stays ON when starting a new game.

I dont know if this exist, but if you use for example switch 5, than in persisten switch ID
is also 5 to check this switch ID.

There is a plugin "Jackkel's Persistent Switches", which might help, but I dont know this
plugin, and no idea if it will work or compitable with olivia's plugin or any other plugin
using switches on event based.

But I think you need something persistent Meta Switch that can be used on Title, and Stays
ON when starting a new game.

Downside might be that this switch will be ALWAYS ON, even when starting a new game
where other players (brother or sister) have this switch ON, instead of OFF.

best way is to make choices when game starts, want hint? yes/no, and turn this
ON or OFF in option inside the game.

this is totally up to you though. but I hope someone can help you out if that plugin
doesn't help you.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top