RMMV how to make the menu stop triggering Scene_Map.prototype.onMapLoaded ?

HenriqueBG

Villager
Member
Joined
Jan 5, 2021
Messages
8
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
I am working on a game where I can "summon" random heroes.
So I have 6 events on the summon map that changes their sprites based in the summons, which are the random heroes.
After the heroes are displayed, I can interact with them to choose which ones will join the party. I can also interact again to remove it from the party. But once I do it (selfSwitch is turned off), the event's page seems to reset. The sprite goes back to the originally defined on the software, and not the changed from code.

I changed the event's page's charsetsName and charsetIndex on $dataMap. Even though the game loaded the original info, probably directly from the database.

I think I can get over it by making everything in the same page. Making it not change.
But is there a way to load the pages from the variable $dataMap instead of the database? It would be much better.
-----------------------------------
Edit: Just noticed it happens only if i open the menu. It seems to load the map again.
My pluging works inside a Scene_Map.prototype.onMapLoaded.
 
Last edited:

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
493
Reaction score
460
First Language
german
Primarily Uses
RMMZ
It's possible to stop the Game from loading when you resume from the menu, but I recommend you to look for something else. Maybe pure eventing here?

Add this as a Plugin:
Code:
var loadedMapId;

(function() {
    const alias = DataManager.loadMapData;
    DataManager.loadMapData = function(mapId) {
        if (loadedMapId != mapId)
            alias(mapId);
    loadedMapId = mapId;
    }
})();

Tell me if it works for you :)
 

HenriqueBG

Villager
Member
Joined
Jan 5, 2021
Messages
8
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
Tell me if it works for you :)
Thanks for the reply!
i got an error:
JavaScript:
rpg_managers.js:1949 TypeError: Cannot read property 'bind' of undefined
    at DataManager.loadMapData (rpg_managers.js:109)
    at Function.DataManager.loadMapData (stopMapReloadFromMenu.js:7)
    at Scene_Map.create (rpg_scenes.js:556)
    at Function.SceneManager.changeScene (rpg_managers.js:2005)
    at Function.SceneManager.updateMain (rpg_managers.js:1982)
    at Function.SceneManager.update (rpg_managers.js:1907)
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
493
Reaction score
460
First Language
german
Primarily Uses
RMMZ
Replace the line
Code:
alias(mapId)
with
Code:
alias.call(this, mapId)


This is the exact code from my Plugin that does work, when copy-pasting it needs some adjustments, but maybe this helps you understanding what I did.

Code:
// Alias
MK.alias.loadMapData = DataManager.loadMapData;
DataManager.loadMapData = function(mapId) {
    if ($dungeonGenerator.mapId != mapId) {
        $dungeonGenerator.leaveRNGArea();
        MK.alias.loadMapData.call(this, mapId);
    }
    // else: do nothing
};

But in the end, I'm not sure if you really want to make a Base function to not do its job in some cases, it has a high chance to raise incompatibilities. In my Plugin, I do a on-the-fly map manipulation, so I really don't want to reload the Map from disk. But still, it's difficult for me to ensure compatibility with other Plugins that alias loadMapData function.
 

HenriqueBG

Villager
Member
Joined
Jan 5, 2021
Messages
8
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
Thanks Aerosys!
I will take a closer look at it. I just want the menu to stop reloading on one map only. not the entire game.
---------------------
Edit:

It works great!
Just in case anyone else comes here in the future:
JavaScript:
var loadedMapId;
const dontReload_MapID = 8; //Add this only if you wanna set what map you want to not reload when openning the menu.

const alias = DataManager.loadMapData;
DataManager.loadMapData = function (mapId) {
    
    if (loadedMapId != mapId) {
        alias.call(this, mapId)
    }
    
    if (mapId == dontReload_MapID) { //Remove the IF, in case you want to the script works on all maps
        loadedMapId = mapId;
    }
    
//Thanks Aerosys for the help
}
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

I just lost an hour plus of time to trying to modify the _battlefield sprite... when in reality MZ calls it _battleField ;_;

Even when debugging for the "undefined value", it looked exactly the same to my 20/60 eyesight.

I really prefer this_naming_convention rather than thisNamingConvention !!
hmm... I just solved one of the more annoying sideview battler problems in MV.. Passive States and Visual States can make it so when your character is in crisis HP, they don't go back to normal walk/wait when it's their turn. they stay in the crisis motion... neat.
Apparently all of LGBT reddit hates me. I posted a simple question and only got hate mail. What's the deal? The doompost was literally 6 months ago and I've changed my views since then and apologized.
MOD NOTE: See second response before replying to this. - Wavelength
Amazing. Simply amazing...

JRPG Browser - Playlist:

Forum statistics

Threads
109,100
Messages
1,042,045
Members
141,585
Latest member
CiderV
Top