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 Profile Posts

KenKrath wrote on RPGMakerWeb's profile.
Hi there!! I saw my Valentines Video placed in the contest. I'm wondering if I placed 3rd or 1st though because my video was shown first but my name is shown as the 3rd video. Thanks for the opportunity :)
I found a book about game localization. It costs R$708,00 on Amazon. ;_;
I really wish my game was far enough along for it to be actually playable beyond certain aspects. I think I've crafted a really fun battle system thanks to ATB, fighting game, and Boost point mechanics.
Play test of my current progress on Happy Camper
Cutscene Contest Winners have been announced!

Forum statistics

Threads
109,112
Messages
1,042,186
Members
141,608
Latest member
Sinthea
Top