Help! Get map data array

Skotty TV

Veteran
Veteran
Joined
Nov 4, 2015
Messages
98
Reaction score
171
First Language
German, English
Primarily Uses
Hi There!


I just want to know if anyone (good scripter) can help me out.


I want to create a new array with all map info stored in ->


- var array = [];


- array[1] = Map001.json


something like this...


The thing is, in $datamap is always just the last map stored. And $dataMapInfos doesnt have all infos i need.


I need the "note" information of each map.


Basicly i just need a new array where all "Map00x.json" objects are stored in.


- DataManager._databaseFiles.push({name: "$datamap1", src: "Map001.json"});


<- This is not a solution because at that point the length of $dataMapInfos is not given,


so a "for loop" has to go up to 999 which will give the error "Map00X is not found".... :(


Help!


The final array should look like this:


$myarray[]


- 0: Map001


       - data


- 1: Map002


       - data


 2: ....
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,047
Reaction score
7,034
First Language
German
Primarily Uses
RMMV
I think you better tell us what you want to do - so far you only told us how you want to do something, not what and why.


Because unfortunaly, storing the entire map-jsons will require a lot of memory, and you won't need 99% of all that data.


So better to tell us what you want to do, because then we might be able to point you to another way that stores only the minimum info you need.


Because there are a lot of reasons why only one map is loaded...
 

Skotty TV

Veteran
Veteran
Joined
Nov 4, 2015
Messages
98
Reaction score
171
First Language
German, English
Primarily Uses
I think you better tell us what you want to do - so far you only told us how you want to do something, not what and why.


Because unfortunaly, storing the entire map-jsons will require a lot of memory, and you won't need 99% of all that data.


So better to tell us what you want to do, because then we might be able to point you to another way that stores only the minimum info you need.


Because there are a lot of reasons why only one map is loaded...


First of all thanks for the quick awnser!


I dont want to store all of it of course... i just want to create an array with all maps noteboxes.


The Plugin i want to create will handle some sort of "Level Selection".


I want to determine the "Chapter" of a map with <Chapter: X> in the Maps Notebox


and the "Level" with <Level: X>.


Another part will be if the Level/Chapter is: Revealed, finished, hidden... etc.


thats why i need to create a new array that will get saved inside a savegame file.


Telling here what the script is for and what it will do exactly would be kinda dumb, i hope you´re with me.


The final array should (now) look like this:


$myarray[]


- 0: Map001


       - note


- 1: Map002


       - note


- 2: ....


How to read a JSON file proper will might be all help i need ->


for (var i = 1; i < $dataMapInfos.length; i++) {


****var tmp = read Json Map(i).note****


      mylist.push(tmp);


        }


...i dunno :(
 

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
For loading a json from the data directory:


function loadData(filename) {
var fs = require('fs');
var dir = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');

if (dir.match(/^\/([A-Z]\:)/)) {
dir = dir.slice(1);
}

filename = decodeURIComponent(dir) + 'data/' + filename + '.json';

return JsonEx.parse(fs.readFileSync(filename, 'utf8'));
};




Wonder how will that be if you use like 200 maps xD
 
Last edited by a moderator:

Skotty TV

Veteran
Veteran
Joined
Nov 4, 2015
Messages
98
Reaction score
171
First Language
German, English
Primarily Uses
For loading a json from the data directory:


Wonder how will that be if you use like 200 maps xD


Nice!


Thank you a lot! BD


Works fine!


Btw: Tested now with 150 maps.... (whole map.json data!)


2-3 Seconds to load game, 138-142 FPS.


So everything is ok :D


You will get credited for your help!


I will send you a private massage as soon the plugin is finished.


This can be closed.
 
Last edited by a moderator:

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
Awesome!


Glad I could help, you don't need to worry about credtis [:


I'll wait the message tho.


Be cautious about that speed, maybe it's fast because your machine is fast. I guess It's always nice to think about the budget players.


Cheers!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Me : "Wearing glasses is annoying."
*put out glasses*
Also me : "Keep mistaking 0, 6 and 8."
oh god, a new version of RPG Maker is coming soon already....
So a new RPG Maker has been teased on RPG Maker Web's Twitter. Hmm...
So in my stream for the No Travel Game Jam, I mentioned we were going to do a teaching make a game from beginning to end series of streams, but it had to wait on an announcement I couldn't make yet before I could start... Keep your eyes on our twitter tonight.
Surprise extra Text Adventure session! Feel free to drop by!

Forum statistics

Threads
98,122
Messages
949,445
Members
129,401
Latest member
YagyuChan
Top