// Populate data if MapData is a CSV string
if (Std.is(MapData, String))
{
// Figure out the map dimensions based on the data string
_data = new Array<Int>();
var columns:Array<String>;
var rows:Array<String> = MapData.split("\n");
heightInTiles = rows.length;
widthInTiles = 0;
var row:Int = 0;
var column:Int;
while (row < heightInTiles)
{
columns = rows[row++].split(",");
if (columns.length < 1)
{
heightInTiles = heightInTiles - 1;
continue;
}
if (widthInTiles == 0)
{
widthInTiles = columns.length;
}
column = 0;
while (column < widthInTiles)
{
//the current tile to be added:
var curTile:Int = Std.parseInt(columns[column]);
//if neko, make sure the value was not null, and if it is null,
//make sure it is the last in the row (used to ignore commas)
#if neko
if (curTile != null)
{
_data.push(curTile);
column++;
}
else if (column == columns.length - 1)
{
//if value was a comma, decrease the width by one
widthInTiles--;
}
else
{
//if a non-int value was passed not at the end, warn the user
throw "Value passed wan NaN";
}
#else
//if not neko, dont worry about the comma
_data.push(curTile);
column++;
#end
}
}
}