[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,616
Reaction score
1,420
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
21,986
Reaction score
11,287
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

Is it strange that dropping acid is improving my game development?
I'm starting to wonder if I should go the Half Minute Hero route with my game. The character's main weapon is logistically way too strong. So I can't really let the player continuously grow it.... But if they had to build it up each time like HMH, that could work. Also it lets me take advantage of my randomly generated maps so much more. Hmm... This could work! :LZSexcite:
std::vector, std::map and std::string. Three reasons why I'd take C++ over C. :D
Today, 1,932 RPG Maker fans died from being too wow'ed. May they rest in peace.

Forum statistics

Threads
99,199
Messages
962,940
Members
130,780
Latest member
hapotot
Top