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

Finished reworking the design of my Itch.io page <3 Back to making plugins.
I kind of want make a map that's just giant version of the player that's they're running around on. Either by stringing together multiple maps or just by shrinking the player sprite for those maps. Actually that might make a fun reveal... The player's on a normal looking map, but then as realization dawns on them it zooms out to show a much larger map that's a giant version of the player. :LZSexcite:
Do you like to practice level design? I do hahahaha! It's not from a specific game, it's just some tests...Fase 1.png
I really need a better indicator of where you can jump up and down though I feel... otherwise I like how this turned out for the first part of the first dungeon of the game.
@Shaz needs to make a website for his plugins. (it can be done easily for free with google sites.) I can't find a database of them anywhere!

Forum statistics

Threads
109,130
Messages
1,042,401
Members
141,628
Latest member
Ocarina654
Top