TheOddFellow

Overactive Artisan Story Crafter
Regular
Joined
Jul 3, 2014
Messages
167
Reaction score
76
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

Regular
Regular
Joined
Mar 28, 2016
Messages
1,641
Reaction score
1,479
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
Regular
Joined
Jul 3, 2014
Messages
167
Reaction score
76
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,907
Reaction score
13,931
First Language
English
Primarily Uses
RMMZ
'Technical Support is for when you can't get the engine to run.
[move]RPGMaker MV[/move]
 

Latest Threads

Latest Profile Posts

My boss asked I bring my laptop to work so he could see my game. I show my coworkers, show them some database stuff, and then my boss asks "so can I fight this final boss you've talked about a lot?" :kaojoy:
Finally started working on my first game, let's see where this gets me :)
Gonna repost this since it's currently tied 1-1! We've seen Strength with our adventurers and Charisma with our merchants, so which DnD stat would you like to see in the next NPC for my advent calendar: Constitution or Wisdom?

And a bonus game: if you can guess what type of character each stat will represent, I’ll make your suggested sprite for Christmas! First person to get it wins, so make your guess!
Steam is going to be forcing me to update my desktop OS for Mac. It's a good thing that my laptop is Windows otherwise some of my work and a lot of game save files for 32-bit games would become unusable for a while.
Last day in Florida and then we head home. It was a fun, relaxing trip with just the wifey poo. Still managed to make some progress on my Game Jam project though.

Forum statistics

Threads
136,846
Messages
1,270,698
Members
180,613
Latest member
mememan
Top