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.
[MV] Get any map's height/width
● ARCHIVED · READ-ONLY
-
-
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 -
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? -
'Technical Support is for when you can't get the engine to run.
[move]RPGMaker MV[/move]