Get a Game Map Object based off map id

Status
Not open for further replies.

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
$dataMapInfos has a list of Id's which is what ill be tapping into, but Game_Map only has id() Which returns the id of the current map. Is there a function that would return me a Game_Map object based off the id passed in?
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
You'd need to create a new Game_Map object, and call the setup function with the map ID you want it to load in. Then you can use the functions and they'll be based on that map. However, keep in mind that many functions in Game_Map reference the $gamePlayer object. You may run into some issues/unexpected behavior if you need to use these functions on two very different maps, because the player is still on the "official" one, not your alternative one you loaded in.

Edit:

Actually looks like they've changed it somewhat from the old versions. You'll also need to change the value of $dataMap, actually. There is the DataManager.loadMapData function, but that's Async so you'll have to wait for it to be done loading before you can use it.
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
I just need to get the events off that map to then parse them and look for specific things. Can I get away with not changing the $dataMap?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Take a look at these 2 functions:

Code:
DataManager.loadDataFile = function(name, src) {    var xhr = new XMLHttpRequest();    var url = 'data/' + src;    xhr.open('GET', url);    xhr.overrideMimeType('application/json');    xhr.onload = function() {        if (xhr.status < 400) {            window[name] = JSON.parse(xhr.responseText);            DataManager.onLoad(window[name]);        }    };    xhr.onerror = function() {        DataManager._errorUrl = DataManager._errorUrl || url;    };    window[name] = null;    xhr.send();};DataManager.loadMapData = function(mapId) {    if (mapId > 0) {        var filename = 'Map%1.json'.format(mapId.padZero(3));        this.loadDataFile('$dataMap', filename);    } else {        this.makeEmptyMap();    }};
You'll need to async load the json file of that map and register a callback to do what you want.
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
so then I wont be doing this because thats more work then its needed to just read the events of every map.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
This would require you to load all map files at start up (Scene_Boot.prototype.create) and block the game while it's being loaded (Scene_Boot.prototype.isReady). A game can very easily contain several hundred maps, so this may take quite a while. Depending on what you want to do, you might want to add a plugin parameter containing a list of map ids to load, so users can decide what to load.
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
this is why I said its more trouble then it worth ... 
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top