- Joined
- Mar 14, 2012
- Messages
- 21
- Reaction score
- 5
- First Language
- French
- Primarily Uses
In VX using Ruby, loading a map and assigning it to a variable was so simple and easy:
map_id = 1@map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))I have some issues doing the same thing in MV. Like probably many of you, I'm inexperience with javascript and web programming, I'll surely learn the trick of the trade, but I'm dealing with a serious deadline right now, and I need to migrate to MV as soon as possible. It's probably one of the only challenge I've met thus far.
Here's some default code snippets from MV to put everyone on the right track.
DataManager.loadMapData = function() { if (mapId > 0) { var filename = 'Map%1.json'.format(mapId.padZero(3)); this.loadDataFile('$dataMap', filename); } else { this.makeEmptyMap(); }};This is probably the most overwhelming part for most people unfamiliar with web programming.
DataManager.loadDataFile = function(object, filename) { var xhr = new XMLHttpRequest(); var url = 'data/' + filename; xhr.open('GET', url); xhr.overrideMimeType('application/json'); xhr.onload = function() { if (xhr.status < 400) { window[object] = JSON.parse(xhr.responseText); DataManager.onLoad(window[object]); } }; xhr.onerror = function() { DataManager._errorUrl = DataManager._errorUrl || url; }; window[object] = null; xhr.send();};Here again, $dataMap make this function inflexible.
So well, I'm wondering if anyone can put together a quick function to assign a map to a variable and then read its properties. Example: loaded_map.width, etc. My current tests didn't work.
Thank you for reading and investigating this topic with me. Anyone helping can be credited as special thanks in my game, if interested. (find more about it here: www.blossomsoft.com/ )
map_id = 1@map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))I have some issues doing the same thing in MV. Like probably many of you, I'm inexperience with javascript and web programming, I'll surely learn the trick of the trade, but I'm dealing with a serious deadline right now, and I need to migrate to MV as soon as possible. It's probably one of the only challenge I've met thus far.
Here's some default code snippets from MV to put everyone on the right track.
DataManager.loadMapData = function() { if (mapId > 0) { var filename = 'Map%1.json'.format(mapId.padZero(3)); this.loadDataFile('$dataMap', filename); } else { this.makeEmptyMap(); }};This is probably the most overwhelming part for most people unfamiliar with web programming.
DataManager.loadDataFile = function(object, filename) { var xhr = new XMLHttpRequest(); var url = 'data/' + filename; xhr.open('GET', url); xhr.overrideMimeType('application/json'); xhr.onload = function() { if (xhr.status < 400) { window[object] = JSON.parse(xhr.responseText); DataManager.onLoad(window[object]); } }; xhr.onerror = function() { DataManager._errorUrl = DataManager._errorUrl || url; }; window[object] = null; xhr.send();};Here again, $dataMap make this function inflexible.
Code:
DataManager.onLoad = function(object) { var array; if (object === $dataMap) { this.extractMetadata(object); array = object.events; } else { array = object; } if (Array.isArray(array)) { for (var i = 0; i < array.length; i++) { var data = array[i]; if (data && data.note !== undefined) { this.extractMetadata(data); } } }};
Thank you for reading and investigating this topic with me. Anyone helping can be credited as special thanks in my game, if interested. (find more about it here: www.blossomsoft.com/ )
Last edited by a moderator:

