AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Although, I've figured out a majourity of what I need, for some reason whenever I try and call $dataMap.events it always returns back null

I've made a simple script

const filename = "Map%1.json".format(mapId.padZero(3)); if (!vendorArray[filename]) { vendorArray[filename] = $dataMap.events; }

Basically when a map is loaded for the first time and is not already stored in the array, it will store all events on that map, I'm using notetags for setup.

My first though was to use Scene_Map as when it is created it loads all map data on that map ID, but that isn't working.

Is there anything I'm missing, I know this is specific but its really important for my game.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,994
Reaction score
1,462
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
What is the context you are trying to get these events?

If you want to get all the events for the current map, you can just use:
JavaScript:
$gameMap.events()
=> It will return all valid events(that are not null)

But if you are on a map, and want to get event data from another map(or before the map is loaded), you can do something like this:

JavaScript:
function getDataMap(mapId) {
    const xhr = new XMLHttpRequest();
    const fileName = "Map%1.json".format(mapId.padZero(3));
    const url = "data/" + fileName;
    xhr.open("GET", url, false);
    xhr.send();
    return JSON.parse(xhr.responseText);
},

So, you can see below that I'm on map id 29 and manage to get the data from map id 2:
1613784021032.png
 

AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Hi there!
What is the context you are trying to get these events?

If you want to get all the events for the current map, you can just use:
JavaScript:
$gameMap.events()
=> It will return all valid events(that are not null)

But if you are on a map, and want to get event data from another map(or before the map is loaded), you can do something like this:

JavaScript:
function getDataMap(mapId) {
    const xhr = new XMLHttpRequest();
    const fileName = "Map%1.json".format(mapId.padZero(3));
    const url = "data/" + fileName;
    xhr.open("GET", url, false);
    xhr.send();
    return JSON.parse(xhr.responseText);
},

So, you can see below that I'm on map id 29 and manage to get the data from map id 2:
View attachment 180118
Guess I didn't dig deep enough in the code I was using data map because it worked in the console so I just assumed it would work in code, it's early morning here but you ve gone above and beyond with your help so I'll assume it works. Thanks for your help
 

AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Hi there!
What is the context you are trying to get these events?

If you want to get all the events for the current map, you can just use:
JavaScript:
$gameMap.events()
=> It will return all valid events(that are not null)

But if you are on a map, and want to get event data from another map(or before the map is loaded), you can do something like this:

JavaScript:
function getDataMap(mapId) {
    const xhr = new XMLHttpRequest();
    const fileName = "Map%1.json".format(mapId.padZero(3));
    const url = "data/" + fileName;
    xhr.open("GET", url, false);
    xhr.send();
    return JSON.parse(xhr.responseText);
},

So, you can see below that I'm on map id 29 and manage to get the data from map id 2:
View attachment 180118
I've managed to get it working it seems getting event information this way you can't use the meta tag, but the note tag itself seems to be functional.

I know this is a way from what I originally asked for, but how would you iterate through all map ids I see nothing in the code nor do I see anything online on how to do it, and it would just make the process a lot easier.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,994
Reaction score
1,462
First Language
Portuguese - Br
Primarily Uses
RMMZ
Do you want to iterate through all map ids, and check their events and meta tags?

JavaScript:
const myDataMaps= []
for(const map of $dataMapInfos){
    if(map){
        const currentMap = EliBook.getDataMap(map.id)
        DataManager.extractMetadata(currentMap)
        myDataMaps.push(currentMap)
    }
}
This will get all the maps and put them inside an array.
The DataManager.extractMetaData will make the meta of the map for you.

But be careful, it can be slow depending on how many maps you have
 

AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Do you want to iterate through all map ids, and check their events and meta tags?

JavaScript:
const myDataMaps= []
for(const map of $dataMapInfos){
    if(map){
        const currentMap = EliBook.getDataMap(map.id)
        DataManager.extractMetadata(currentMap)
        myDataMaps.push(currentMap)
    }
}
This will get all the maps and put them inside an array.
The DataManager.extractMetaData will make the meta of the map for you.

But be careful, it can be slow depending on how many maps you have
Thanks for the help, if its laggy I'll probably just set up checkpoints at certain parts in the game.
 

AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Do you want to iterate through all map ids, and check their events and meta tags?

JavaScript:
const myDataMaps= []
for(const map of $dataMapInfos){
    if(map){
        const currentMap = EliBook.getDataMap(map.id)
        DataManager.extractMetadata(currentMap)
        myDataMaps.push(currentMap)
    }
}
This will get all the maps and put them inside an array.
The DataManager.extractMetaData will make the meta of the map for you.

But be careful, it can be slow depending on how many maps you have
I'm firing the function when a new game is started, but it says EliBook is not defined, and I can't seem to find it in any of the rpg maker js files. Is it one of your plugins?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,994
Reaction score
1,462
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi!
Sorry, just replace the Eli Book with the "getDataMap" function that I send to you before
function getDataMap(mapId) { const xhr = new XMLHttpRequest(); const fileName = "Map%1.json".format(mapId.padZero(3)); const url = "data/" + fileName; xhr.open("GET", url, false); xhr.send(); return JSON.parse(xhr.responseText); },
 

AwfullyBritish

Villager
Member
Joined
Feb 7, 2021
Messages
17
Reaction score
7
First Language
English
Primarily Uses
N/A
Hi!
Sorry, just replace the Eli Book with the "getDataMap" function that I send to you before
Once again, thank you so much. This was better than what I asked for and everything so far I have tested is working perfectly.
 

Latest Posts

Latest Profile Posts

Quite the versatile cast so far :p

chars.PNG

Edit: Sprites are made by Alexdraws and TheMightyPalm. I just edited them.
Degica Games Turn Komodo | RPG Maker News #77

Well, rats. Was really looking forward to trying out FPS Creator, but trying to install and set it up was pretty much impossible for my tiny brain to comprehend. So much for that, then.
Ah, home once more! I think I can safely work on my games now.
Let's hope power remains on for the day

Forum statistics

Threads
112,412
Messages
1,068,120
Members
146,062
Latest member
BuckyBattleBorn
Top