I'm trying to read maps from Tiled into my game, and I've hit an interesting roadblock: the json is now longer than the string data type allows.
The only way I can find of parsing the json is by passing the whole thing as a string into the .fromJSON function of a user-defined type. Is there a way I could get around the string size limit other than splitting out the actual map data into a separate csv file and having the json point to that?
Here's the code I'm currently using to read the map data from the json file:
TYPE TiledRootType
compressionlevel as integer
height as integer
infinite as integer
layers as TiledLayerType []
nextlayerid as integer
nextobjectid as integer
orientation as string
renderorder as string
tiledversion as string
tileheight as integer
tilesets as TiledTilesetType []
tilewidth as integer
_type as string
version as string
width as integer
ENDTYPE
TYPE TiledLayerType
data as integer []
height as integer
id as integer
name as string
opacity as integer
_type as string
visible as integer
width as integer
x as integer
y as integer
ENDTYPE
TYPE TiledTilesetType
firstgid as integer
source as string
ENDTYPE
FUNCTION ReadMap(MapToPopulate ref as MapType, Filename as string)
JsonData as string
file = OpenToRead(Filename)
WHILE NOT FileEOF(file)
JsonData = JsonData + ReadLine(file)
ENDWHILE
Root as TiledRootType
Root.fromJSON(JsonData)
MapToPopulate.tiles.length = Root.layers[0].width - 1
FOR i = 0 TO MapToPopulate.tiles.length
MapToPopulate.tiles[i].length = Root.layers[0].height - 1
NEXT i
FOR i = 0 TO Root.layers[0].data.length
MapToPopulate.tiles[Mod(i, Root.layers[0].width), Floor(i/Root.layers[0].width)].collision = Root.layers[0].data[i]
NEXT i
CloseFile(file)
ENDFUNCTION