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.
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 ?
That's what auto-run events are for.
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 :/
You just disable menu once and that's it. You don't havre to disable it every frame or on every map separately.
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.
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?
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.
*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.
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?
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.