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
514
Reaction score
488
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
514
Reaction score
488
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

unknown.png

A sketch of a character for an upcoming chapter. I am pre-preparing the heck out of this one and future chapters, don't want to spend time figuring the story out again. :blush:
Today *Fix the game UI
RMMZ maxRows make me tired.
The game supports real-time language switching (really interesting).
8laFKAa.png


jBYDFzZ.png


lYbvPth.png

mY99lgU.png

Swag collecting in the new randomly generated area. Now the mini map also shows the randomly generated features... And even illustrates the whole "bubble" system" that I made to manage memory... Though that part's inadvertent. We'll just call that "the fog of war"... Yes, that's what we'll do. Nobody will be the wiser! :kaopride:
not me being not lazy for 5 seconds and drawing another char portrait (her name is hazel)
its_hazel.png
Been a while since the last time I made a song remix. Had a blast making this

Forum statistics

Threads
110,457
Messages
1,053,463
Members
143,550
Latest member
manyattempts
Top