[MV] Get any map's height/width

TheOddFellow

Overactive Artisan Story Crafter
Veteran
Joined
Jul 3, 2014
Messages
152
Reaction score
67
First Language
English
Primarily Uses
RMMV
Question: How can I get the width and height of any map within my game?
"$dataMap.height" and "$dataMap.width" will get the data only of the map I am currently on.
I've tried using IDs in multiple ways to access data to maps I have previously made, but to no avail.

I've searched a lot of google, and checked out to see if there are answers to this question over several days. I've checked script call lists, googled ".height", "$dataMap", "$dataMap" and so on in many possible combinations.

Please, if anyone can help me, I would greatly appreciate it.

Why? You might ask. Well, I'm building a game which has many different sizes, and instead of programming each event in, I would be using the difference in height and width to make the teleportation work.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,617
Reaction score
1,426
First Language
French
Primarily Uses
RMMV
hum map json are loaded only each time your transfer Scene with a ID .
You can store all map Json data in a globale if you want.
It called Cache
Maybe am wrong but I don't think Rmmv cache json.

So you need make your own cache loader at boot , and store all map data for access.
Example on my side

PHP:
// ┌-----------------------------------------------------------------------------┐
// LOADER JSON
// special boot once loader for json
//└------------------------------------------------------------------------------┘
// $Loader.preLoad_Json();
_coreLoader.prototype.preLoad_Json = function() {
    // MapInfos and Scene### base
    const L0 = function(){
        const loader0 = new PIXI.loaders.Loader();
        for (const key in this._JsonPath) {
            loader0.add(key, this._JsonPath[key]);
        };
        loader0.load();
        loader0.onProgress.add((loader, res) => {
            this.loaderSet[res.name] = res.data;
        });
        loader0.onComplete.add((loader, res) => {
            L1.call(this);
        });
    };
    L0.call(this);
    const L1 = function(){
        // Scene_Map
        const loader1 = new PIXI.loaders.Loader();
        this.loaderSet.Scene_Map = {};
        this.loaderSet.MapInfos.forEach(map => {
            if(map){
                const id = map.id.padZero(3);
                const path = `data/Map${id}.json`;
                loader1.add(id, path);
            };
        });
        loader1.load();
        loader1.onProgress.add((loader, res) => {
            this.loaderSet.Scene_Map[res.name] = res.data;
            res.data.data = null; // clear the rmmv data
        });
        loader1.onComplete.add((loader, res) => {
            L2.call(this);
        });
    };

    const L2 = function(){
        // Scene_Map .DATA
        const loader2 = new PIXI.loaders.Loader();
        this.loaderSet.MapInfos.forEach(map => {
            if(map){
                const id = map.id.padZero(3);
                const path = `data/Map${id}_data.json`;
                loader2.add(id, path);
            };
        });
        loader2.load();
        loader2.onProgress.add((loader, res) => {
            this.loaderSet.Scene_Map[res.name].data = res.data;
        });
        loader2.onComplete.add((loader, res) => {
            L3.call(this);
        });
    };

    const L3 = function(){
        // build planet information
        this.loaderSet.PlanetsInfos = {};
        for (const key in this.loaderSet.Scene_Map) {
            const data = this.loaderSet.Scene_Map[key].data;
            const planetID = data.planet;
            // registering all planet id existe from rmmv comment json
            if(planetID && !this.loaderSet.PlanetsInfos[planetID]){
                this.loaderSet.PlanetsInfos[planetID] = {};
            };
            // scan all game maps and store sheets need for each planet id
            for (const sheetKey in data.sheets) {
                this.loaderSet.PlanetsInfos[planetID][sheetKey] = data.sheets[sheetKey];
            };
        };
       this._scene.isLoading = false; // allow continue scene laoder
    };
};

Don't worry about memory, json string take very small memory slots.
Or maybe your can have issue if your have 512 mo memory ram ! but we are in 2018! :beard
 

TheOddFellow

Overactive Artisan Story Crafter
Veteran
Joined
Jul 3, 2014
Messages
152
Reaction score
67
First Language
English
Primarily Uses
RMMV
This seems... Awfully complex... Or, perhaps the answer to my question requires as such. My maps will be changing a lot, and I needed a simple way to teleport only using different maps widths and heights.
Like; "$gameVariables.value()" or the like?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,112
Reaction score
11,461
First Language
English
Primarily Uses
RMVXA
'Technical Support is for when you can't get the engine to run.
[move]RPGMaker MV[/move]
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.
is there a script call that return how much turn has passed in battle?

Forum statistics

Threads
100,607
Messages
977,781
Members
132,220
Latest member
lightnvs
Top