Problem with table serialization
Posted: Wed Jul 13, 2016 7:49 pm
Hey,
I have problem while loading (or saving, I don't really know) my map, it does things like these :
here's the code :
Hope you can help me !
I have problem while loading (or saving, I don't really know) my map, it does things like these :
here's the code :
Code: Select all
-- this is for import map to string
function map2string(maptable,typeser)
local sz = ''
for y = 0, map.height do
local row = {}
for x = 0, map.width do
local c = typeser[maptable[x][y]]
c = (c ~= nil) and c or ' '
if not tostring(c):len() == 1 then
error("non-ANSI character on:" .. x .. ',' .. y)
end
row[x] = c
end
sz = sz .. table.concat(row) .. '\n'
end
return sz
end
-- this is for import string to map
local x, y = 0, 0
for l in string.gmatch(love.filesystem.read(file), "(.-)\n") do
for c in string.gmatch(l, ".") do
if map_signloader[c] ~= "nil" and x < map.width+1 then
map_level[x][y] = map_signloader[c]
end
x = x + 1
end
x, y = 0, y + 1
end