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
517
Reaction score
491
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
517
Reaction score
491
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

It seems that I have to change the order with which I make the fantasy games on my bucket list, because the intended title is used as a story element in the first two games in the line, and somebody else might take the title for their own game because the term uses real words. I can't risk going over the apparent three year limit for registering trademark ahead of time.
I am interested in collaborations so if you like my art, hit up my messages! :wub
unknown.png

Making good progress with the second chapter. :)

Still work in progress.

(Real life, it is chronically the fourth chapter that I am making.)
constructionworkconcept.pngezgif-2-0acb620ecf8d.gifezgif-2-afeaf16ebb8d.gif "The Great Wall is great. But, most people can only be the slaves who built it, leaving their bones underneath that wall. They spent their whole life to build that wall and the empire, an empire that enslaves them." :kaoswt2: I'm just going to turn it into a modern-day sad tale.

Forum statistics

Threads
110,672
Messages
1,055,088
Members
143,795
Latest member
IrishEngineer13
Top