[RMMZ] HOW TO CALL A COMMON EVENT THROUGH A MENU? (VS MAINMENU CORE)

Posts

Pages: 1
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
So I'm working on my game and there are certain features trigged by common events I want to have available on the main menu. I'm using Visustella Menu Core and tried to use the default placements of "commonEvent1" and "commonEvent2" to trigger Common Event 52 and 55 instead. However, since I don't know javascript, I messed up somewhere in there and now my game crashes whenever I try to trigger the common events. Here is the code in the plugin parameters:

Symbol: commonEvent52

Icon: 88
STR: Text: Journal
JS: Text: return 'Text';
JS: Show: return true;
JS: Enable: return this.areMainCommandsEnabled();
JS: Ext: return 52;
JS: Run Code: SceneManager._scene.commandCommonEvent();
JS: Personal Code: const ext = arguments[0];


and for the second one...

Symbol: commonEvent55

Icon: 88
STR: Text: Journal
JS: Text: return 'Text';
JS: Show: return true;
JS: Enable: return this.areMainCommandsEnabled();
JS: Ext: return 55;
JS: Run Code: SceneManager._scene.commandCommonEvent();
JS: Personal Code: const ext = arguments[0];


Can anyone please help me with this? Thanks!
unity
You're magical to me.
12540
I don't know Javascript, but looking over your VS Menu Core settings for common events and mine, I can't see any difference other than my "JS: Enable" is "return true;" but I don't think that's likely to be causing the problem?

What error do you get when you try to run the Common Event?

And did you get that project from your previous thread working?
Marrend
Guardian of the Description Thread
21781
Well, the line "JS: Enable: return this.areMainCommandsEnabled();" is probably the enabled/disabled state of the option. So, like, for example, if you use the event-command that disables the save option, that grays the "Save" menu option out, and it cannot be chosen. It's something similar to that. To use "return true" in that case means that it is always enabled.


However, under normal conditions, you can call a common event through code via something like...
$gameTemp.reserveCommonEvent(id);
...this? Not 100% sure. I looked up the Ace Script Call library for a bit of reference on this point. While MZ/MV are made with Java, and Ace with Ruby, various concepts are similar. Common Events being one of them.


*Edit: The line...
JS: Run Code: SceneManager._scene.commandCommonEvent();
...that says this is jumping out at me a little? What does "commandCommonEvent()" do in this context? Maybe that's the error? Like, could/should there be a common event ID in those parenthesis? However, since I don't know how this plug-in works, I'm probably wrong.


*Edit2: I don't know if this helps, but, I'm looking at that data, and seeing how the information could be plugged into an instance of Window_Command...
Window_Command.prototype.addCommand = function(
    name, symbol, enabled = true, ext = null
) {
    this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext });
};
...and how it could interact with Scene_Menu...
Scene_Menu.prototype.createCommandWindow = function() {
    const rect = this.commandWindowRect();
    const commandWindow = new Window_MenuCommand(rect);
    commandWindow.setHandler("item", this.commandItem.bind(this));
    commandWindow.setHandler("skill", this.commandPersonal.bind(this));
    commandWindow.setHandler("equip", this.commandPersonal.bind(this));
    commandWindow.setHandler("status", this.commandPersonal.bind(this));
    commandWindow.setHandler("formation", this.commandFormation.bind(this));
    commandWindow.setHandler("options", this.commandOptions.bind(this));
    commandWindow.setHandler("save", this.commandSave.bind(this));
    commandWindow.setHandler("gameEnd", this.commandGameEnd.bind(this));
    commandWindow.setHandler("cancel", this.popScene.bind(this));
    this.addWindow(commandWindow);
    this._commandWindow = commandWindow;
};
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
Nevermind I've given up on MZ. I'm using MV now. Screw MZ.
Pages: 1