Always disable menu plugin

● ARCHIVED · READ-ONLY
Started by Astro785 16 posts View original ↗
  1. Hello !
    I've made this very simple plugin which is supposed to always disable the menu opened with ESC key, from any maps :

    Code:
    //=============================================================================
    // disableMenu.js
    //=============================================================================
    
    /*:
     * @plugindesc Always disable the game menu.
     * @author Astro785
     *
     * @help This plugin does not provide plugin commands.
     */
    
    
    (function() {
    
      $gameSystem.disableMenu();
    
    })();

    I've activated it inside my game's plugins, but I am still able to open the menu with the ESC key.

    Any insights of why it doesnt work ?

    Thanks ! :rock-right:
  2. Because $gameSystem is not yet defined when the function gets called.
    Anyway, why would you need that? There is already an event command for that.
  3. How should I do then ?

    If it isn't with a plugin, how can I create an event that run immediatly when the game start, on any map where the player spawns ?
  4. That's what auto-run events are for.
  5. Autorun event prevents the player from moving, and is only triggered when entering the map where it has been placed. I want the menu to be disable anywhere on my game, without having to place a parallel event on every maps.

    I tried with common events too, but those needs a switch to be activated, so it's the same problem. Plus it's a one time command, I don't want it to be run continuously in the background :/
  6. You just disable menu once and that's it. You don't havre to disable it every frame or on every map separately.
  7. I see where we don't understand each other here. I'm working on a mmo rpg game, so there is no such thing has "save" and "load" game state. Each time the user is logged in to my game, he get spawned where it was disconnected before, like in all mmo.
    The thing is, if I set the disable menu event for example in MAP001 only, and the user goes to MAP002 (which doesnt have the disable menu event), then disconnect and relog ( so he will spawn on MAP002 ), he will be able to open the menu, which I don't want.
  8. And what does it matter?
    In order for the player to continue from where they left of, there must be some data saved somewhere, INCLUDING system data, in other words $gameSystem, player data, in other words particular $gamePlayer, party data, in other words $gameParty and actor data, in other words $gameActor.
    Are you telling me that whatever will handle saving your data, will remember the entire $gameSystem object, but will not remember the information that he can't open menu, which is exactly stored inside $gameSystem?
  9. Dev console is your friend. If you press F8 during a playtest it would have shown you the reason right there:

    Spoiler
    2018-03-24 10_20_59-Developer Tools - chrome-extension.png

    To your other point, you don't plan to have any save state in this game?
    The players items / gold / exp doesn't get saved?
    Whether or not the menu is disabled is part of the save data.
    Edit: Poryg said this part better.
  10. I didn't know that $gamePlayer had this information in it. Thank you for patience i'm still learning the way RPG Maker works behind the scene and I just found the full documentation.
  11. *gameSystem. I made a mistake in my previous post, but edited it quickly.
    Also, this isn't about MV, it's about computer logic. Computers don't have implicit knowledge, so when you turn something on or off, this value has to be stored somewhere. Otherwise the computer can't work with it.
  12. I understand thank you.

    And just for the science, how should I have done if I wanted my piece of code to wait for $gameSystem to be defined?
  13. You would not define it as a self invoking function, but as a function that can be called and call it at the right time. In other words after either New game command has been selected or game has been loaded.
  14. Something like this:

    Code:
    (function() {
    
    var oldDataManager_SetupNewGame = DataManager.setupNewGame
    DataManager.setupNewGame = function() {
    oldDataManager_SetupNewGame.call(this)
    $gameSystem.disableMenu()
    };
    
    })()

    But, as @Poryg said, no need for a plugin for doing something like this.
    The disableMenu method is only a function that switch the value of a variable to false.
    That variable is used as condition for calling the menu inside of a map.
    So, using the related event command at the start of the game has the same effect.
  15. Like others have said, instead of a plugin, you'd make an Autorun event that only runs once at the beginning of the game to disable the menu.

    But as a learning exercise: in your case the code would probably work if you did this:
    Code:
    var Game_System_initialize = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function() {
        Game_System_initialize.call(this);
        this.disableMenu();
    };
    Basically, you extend the Game_System's initialize function to disable the menu after initialization.
  16. Nolonar said:
    Like others have said, instead of a plugin, you'd make an Autorun event that only runs once at the beginning of the game to disable the menu.

    But as a learning exercise: in your case the code would probably work if you did this:
    Code:
    var Game_System_initialize = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function() {
        Game_System_initialize.call(this);
        this.disableMenu();
    };
    Basically, you extend the Game_System's initialize function to disable the menu after initialization.

    Thank you very much ! It helps me understand a lot of things!