Add a custom option to the "Options" menu?

Banjo

Veteran
Veteran
Joined
Jan 4, 2013
Messages
92
Reaction score
19
First Language
English
Primarily Uses
RMVXA
How do I add a custom option to the main menu "Options" screen? I'd like to be able to run a common event from there ideally, if not toggle a switch or use a plugin command.

I'm assuming doing this may require a 3rd party plugin, which is fine, but I've not been able to find one that seems able to do this for MV.

EDIT: it seems this is possible *in theory* for Yanfly's Options Core... right?

If so, how do I make a custom option that runs a plugin command when selected? Driftwoodgaming have a video on a custom switch toggle, but I've no idea where to start for coding it to handle a plugin command!

EDIT 2:
I did it! Got a plugin command to run using a workaround by also adding Yanfly's Script Call Plugin. :)

So the only thing left is running a common event...?
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
It will involve scripting. Can you specify exactly what plugin command you want to use, and which plugin it's from? :)

Note: if the options menu is accessible from the title screen, stuff like toggling switches or running common events will, at best, not do anything. E.g. game switches get reset when starting a new game or loading a save.

Also, RPG Maker events run through an interpreter: by default the only interpreters are on the map and battle scenes...everywhere else (e.g. pause menu, options, etc) has no support for running events. That's why items/skills with common event effects exit the menu to run their event.
 

Banjo

Veteran
Veteran
Joined
Jan 4, 2013
Messages
92
Reaction score
19
First Language
English
Primarily Uses
RMVXA
So, here's what I've got so far. Hopefully this not only helps people answer my queries but aids others trying to do the same thing in the future!

The main reason for me wanting this is to use with SMO's Achievement plugin. Because those achievements are saved separate to normal save files, I wanted the player to be able to "wipe" their achievements and start over if they wanted to. This is also helpful for debugging!

I have added the following plugins in addition to SMO's Achievements:
- Yanfly's Script Call Plugin Cmd
- Yanfly's Options Core
- Olivia's MetaControls

SMO Achievements resets plugins with the "ResetAchievementsData" plugin command normally.

Using YEP Script Call Plunin Cmd, this translates to:
JavaScript:
 var line = 'ResetAchievementsData';
 CallPluginCommand(line);
So I created a new option category in YEP Options Core as follows:
Code:
{"Name":"\\i[191]Progress","---Settings---":"","HelpDesc":"\"Manage achievements.\"","OptionsList":"[\"{\\\"Name\\\":\\\"\\\\\\\\i[191]Reset Achievements\\\",\\\"---Settings---\\\":\\\"\\\",\\\"HelpDesc\\\":\\\"\\\\\\\"Resets ALL achievements you've unlocked.\\\\\\\"\\\",\\\"Symbol\\\":\\\"resetAchievements\\\",\\\"ShowHide\\\":\\\"\\\\\\\"show = true;\\\\\\\"\\\",\\\"Enable\\\":\\\"\\\\\\\"enabled = true;\\\\\\\"\\\",\\\"Ext\\\":\\\"\\\\\\\"ext = 0;\\\\\\\"\\\",\\\"---Functions---\\\":\\\"\\\",\\\"MakeCommandCode\\\":\\\"\\\\\\\"this.addCommand(name, symbol, enabled, ext);\\\\\\\"\\\",\\\"DrawItemCode\\\":\\\"\\\\\\\"var rect = this.itemRectForText(index);\\\\\\\\nvar statusWidth = this.statusWidth();\\\\\\\\nvar titleWidth = rect.width - statusWidth;\\\\\\\\nthis.resetTextColor();\\\\\\\\nthis.changePaintOpacity(this.isCommandEnabled(index));\\\\\\\\nthis.drawOptionsName(index);\\\\\\\\nthis.drawOptionsOnOff(index);\\\\\\\"\\\",\\\"ProcessOkCode\\\":\\\"\\\\\\\"var index = this.index();\\\\\\\\nvar symbol = this.commandSymbol(index);\\\\\\\\nvar value = this.getConfigValue(symbol);\\\\\\\\nthis.changeValue(symbol, !value);\\\\\\\\n\\\\\\\\nvar line = 'ResetAchievementsData';\\\\\\\\nif (value == true) {\\\\\\\\n  CallPluginCommand(line);\\\\\\\\n}\\\\\\\"\\\",\\\"CursorRightCode\\\":\\\"\\\\\\\"var index = this.index();\\\\\\\\nvar symbol = this.commandSymbol(index);\\\\\\\\nvar value = this.getConfigValue(symbol);\\\\\\\\nthis.changeValue(symbol, true);\\\\\\\"\\\",\\\"CursorLeftCode\\\":\\\"\\\\\\\"var index = this.index();\\\\\\\\nvar symbol = this.commandSymbol(index);\\\\\\\\nvar value = this.getConfigValue(symbol);\\\\\\\\nthis.changeValue(symbol, false);\\\\\\\"\\\",\\\"DefaultConfigCode\\\":\\\"\\\\\\\"ConfigManager[symbol] = false;\\\\\\\"\\\",\\\"SaveConfigCode\\\":\\\"\\\\\\\"config[symbol] = ConfigManager[symbol];\\\\\\\"\\\",\\\"LoadConfigCode\\\":\\\"\\\\\\\"ConfigManager[symbol] = config[symbol];\\\\\\\"\\\"}\",\"{\\\"Name\\\":\\\" \\\",\\\"---Settings---\\\":\\\"\\\",\\\"HelpDesc\\\":\\\"\\\\\\\" \\\\\\\"\\\",\\\"Symbol\\\":\\\"none\\\",\\\"ShowHide\\\":\\\"\\\\\\\"show = true;\\\\\\\"\\\",\\\"Enable\\\":\\\"\\\\\\\"enabled = true;\\\\\\\"\\\",\\\"Ext\\\":\\\"\\\\\\\"ext = 0;\\\\\\\"\\\",\\\"---Functions---\\\":\\\"\\\",\\\"MakeCommandCode\\\":\\\"\\\\\\\"this.addCommand(name, symbol, enabled, ext);\\\\\\\"\\\",\\\"DrawItemCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"ProcessOkCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"CursorRightCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"CursorLeftCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"DefaultConfigCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"SaveConfigCode\\\":\\\"\\\\\\\"\\\\\\\"\\\",\\\"LoadConfigCode\\\":\\\"\\\\\\\"\\\\\\\"\\\"}\"]"}
And inside that is a single option, to Reset Achievements:
Code:
{"Name":"\\i[191]Reset Achievements","---Settings---":"","HelpDesc":"\"Resets ALL achievements you've unlocked.\"","Symbol":"resetAchievements","ShowHide":"\"show = true;\"","Enable":"\"enabled = true;\"","Ext":"\"ext = 0;\"","---Functions---":"","MakeCommandCode":"\"this.addCommand(name, symbol, enabled, ext);\"","DrawItemCode":"\"var rect = this.itemRectForText(index);\\nvar statusWidth = this.statusWidth();\\nvar titleWidth = rect.width - statusWidth;\\nthis.resetTextColor();\\nthis.changePaintOpacity(this.isCommandEnabled(index));\\nthis.drawOptionsName(index);\\nthis.drawOptionsOnOff(index);\"","ProcessOkCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, !value);\\n\\nvar line = 'ResetAchievementsData';\\nif (value == true) {\\n  CallPluginCommand(line);\\n}\"","CursorRightCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, true);\"","CursorLeftCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, false);\"","DefaultConfigCode":"\"ConfigManager[symbol] = false;\"","SaveConfigCode":"\"config[symbol] = ConfigManager[symbol];\"","LoadConfigCode":"\"ConfigManager[symbol] = config[symbol];\""}
For much better clarity, the important parts (I think) are the DrawitemCode and ProcessOkCode sections.

If I make ProcessOkCode:
JavaScript:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
this.changeValue(symbol, !value);

var line = 'ResetAchievementsData';
CallPluginCommand(line);
... then pressing "Okay" on that option works and Achievements are reset.

However, what I can't figure out is how to make that option just say "Reset" that you click, instead of an on/off toggle. Alternately, if it has to be "on/off", that the achievements are *only* reset if you set it to "on" and then press okay. Hope that makes sense!

Finally, in regards to switches persisting across saves, etc... that's why I am using the SMO Achievements Plugin. However, I have also just tried out the fantastic Olivia's MetaControls plugin since it indeed allows switches and variables to persist, it seems. This would be perfect if I (or someone else) wants to make a YEP Options Core option that toggled a specific switch or changed a value that persisted across all saves (i.e. anything other than achievements).

Although MetaControls will also let you run a common event on load (and new game), however, I still can't figure out how a custom Options Core option can run one. Maybe it's not possible without more plugins or scripts, but thankfully that's not something I really need and was more of a curiosity.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Oh I see! Yea, you'll want to edit the Draw Option Code part. Try this setup:
  • Make Option Code:
    JavaScript:
    this.addCommand(name, symbol, enabled, ext);
  • Draw Option Code:
    JavaScript:
    var rect = this.itemRectForText(index);
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawOptionsName(index);
  • Process OK:
    JavaScript:
    CallPluginCommand('ResetAchievementsData');
I think the other code fields can be left blank (""): no need for left/right arrows, and there's no value associated with the option so the default/save/load code is all unnecessary. I tested this using a simple text alert for the Process OK thing and it seemed to work OK for me! :kaojoy:

Edit:
Although MetaControls will also let you run a common event on load (and new game), however, I still can't figure out how a custom Options Core option can run one. Maybe it's not possible without more plugins or scripts, but thankfully that's not something I really need and was more of a curiosity.
For this, maybe make your common event check for a config setting and act accordingly? E.g. Conditional Branch > Script:
JavaScript:
ConfigManager['alwaysDash']
This condition will pass if the option with symbol "alwaysDash" is set to true (or something truthy). :kaothx:
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,685
First Language
English
Primarily Uses
RMMZ

I've moved this thread to Javascript/Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Banjo

Veteran
Veteran
Joined
Jan 4, 2013
Messages
92
Reaction score
19
First Language
English
Primarily Uses
RMVXA
Oh I see! Yea, you'll want to edit the Draw Option Code part. Try this setup:
  • Make Option Code:
    JavaScript:
    this.addCommand(name, symbol, enabled, ext);
  • Draw Option Code:
    JavaScript:
    var rect = this.itemRectForText(index);
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawOptionsName(index);
  • Process OK:
    JavaScript:
    CallPluginCommand('ResetAchievementsData');
I think the other code fields can be left blank (""): no need for left/right arrows, and there's no value associated with the option so the default/save/load code is all unnecessary. I tested this using a simple text alert for the Process OK thing and it seemed to work OK for me! :kaojoy:

Edit:

For this, maybe make your common event check for a config setting and act accordingly? E.g. Conditional Branch > Script:
JavaScript:
ConfigManager['alwaysDash']
This condition will pass if the option with symbol "alwaysDash" is set to true (or something truthy). :kaothx:
That's really helpful, thanks! Trying it now. I hope this helps others who might come along looking to do the same things, as I could find *nothing* anywhere here or elsewhere about this.

Is there a way to make a popup "are you sure?" box? If not, no big issue, just wondering.

[MOVE]Javascript/Plugin Support[/MOVE]
Thanks for the move, however the topic started as a general MV question but evolved into a javascript (or indeed, specific plugin) discussion once it became apparent that the native program couldn't do what was needed. Hence why it was posted where it was first.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Don't worry, that blue mod-text is a canned response, you're not in trouble. :kaothx:

Is there a way to make a popup "are you sure?" box? If not, no big issue, just wondering.
It's possible but I'd definitely consider writing a separate plugin at that point. :kaoswt:

A very basic but non-immersive solution could be to use the default JavaScript OK/Cancel message box, e.g.
JavaScript:
if (confirm('Reset all achievements?')) CallPluginCommand('ResetAchievementsData');

To make it more like the To Title/Cancel choice seen when choosing End Game from the pause menu, you'd need a game window with the appropriate labels and choice handlers on the options scene: typically that would mean adding/extending a bunch of methods, which is plugin territory. You might be able to rig it somehow...maybe set the To Title/Cancel database terms vaguely enough that you can use a Window_GameEnd instance here as well, then you'd just need to figure out a nice way to add/activate/remove the Yes/No window/handlers on demand. I'm not sure how best to go about that though. :kaoslp:

Maybe there's an elegant way, using only Options Core, to make the "reset" option less easy to accidentally activate? I'm drawing a blank there too. :kaoblush:
 

Banjo

Veteran
Veteran
Joined
Jan 4, 2013
Messages
92
Reaction score
19
First Language
English
Primarily Uses
RMVXA
Don't worry, that blue mod-text is a canned response, you're not in trouble. :kaothx:


It's possible but I'd definitely consider writing a separate plugin at that point. :kaoswt:

A very basic but non-immersive solution could be to use the default JavaScript OK/Cancel message box, e.g.
JavaScript:
if (confirm('Reset all achievements?')) CallPluginCommand('ResetAchievementsData');

To make it more like the To Title/Cancel choice seen when choosing End Game from the pause menu, you'd need a game window with the appropriate labels and choice handlers on the options scene: typically that would mean adding/extending a bunch of methods, which is plugin territory. You might be able to rig it somehow...maybe set the To Title/Cancel database terms vaguely enough that you can use a Window_GameEnd instance here as well, then you'd just need to figure out a nice way to add/activate/remove the Yes/No window/handlers on demand. I'm not sure how best to go about that though. :kaoslp:

Maybe there's an elegant way, using only Options Core, to make the "reset" option less easy to accidentally activate? I'm drawing a blank there too. :kaoblush:
Thanks again! That code indeed worked great! Not he most immersive or nice looking, but far better than nothing!

Like you say, a more native looking version using the game's matching Window skin would be ideal, but I have *zero* knowledge of writing plugins!

Thanks again for all your help.

PS Haven't tried it, but the idea for the common event workaround sounds neat too.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top