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.