Execute common event before command menu

Hi!


I want to execute a common event before the command menu is opened. Well, I have tried this on my plugin:


var callMenu = Scene_Map.prototype.callMenu;

Scene_Map.prototype.callMenu = function() {

$gameTemp.reserveCommonEvent(1);
callMenu.call(this, arguments);

};




Well, so far it works, but with one essential fault: The common event will be execute after the menu was closed, not before it was opened.


I think it's because the event is "marked" as to be executed, but as long as the menu scene is on the run, it can't be executed. So there should be 2 possible solutions, I think: call the event before the menu was involved (but I don't know, where I should trigger this) or before callMenu.call the execute of the common event must be forced (again, I don't know how this would be possible).


Any hints?


Kind regards,


Purzelkater
there is trick


you can make it like this


Scene_Map.prototype.callMenu = function() {
$gameTemp.reserveCommonEvent(1);
if ($gameSwitches.value(1)==false){
callMenu.call(this, arguments);
};
};


make the switch on before the common event then make it false and put 
SceneManager.push(Scene_Menu);
The following code should prevent the menu from opening until after the event is executed:

Code:
var oldSceneMapIsBusy = Scene_Map.prototype.isBusy;
Scene_Map.prototype.isBusy = function() {
  return $gameTemp.isCommonEventReserved() || oldSceneMapIsBusy.call(this);
};
Thank you both, I will try it. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/execute-common-event-before-command-menu.59754/