[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,122
Reaction score
11,489
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 Profile Posts

My old project is now a sitcom
How to do implementation the social politcal mechanics in rpg maker? Thank you for quick spark of ideas. Fear of going to the thread lol.
MerlinCross wrote on Switz's profile.
Not sure if you'll see this but I stumbled across your "Open Locker" sprite in a topic. Could I use those?
topic in question
Going to watch an episode of The Office and eat something after this little progress!

Forum statistics

Threads
100,780
Messages
979,424
Members
132,416
Latest member
Vaztar_Charko
Top