(SOLVED) reading a file with love.filesystem.lines
Posted: Fri Jan 20, 2017 6:17 pm
Hello !
So I'm new with LÖVE and I'm trying to make a simple game first.
So I have a file that contains the informations about a map, like this :
And I'm trying to put the numbers in a matrix by reading the file with love.filesystem.lines() :
But when I try to print the matrix I have this instead of the thing above :
The print function looks like this :
Thanks for your help (and sorry for my english) !
So I'm new with LÖVE and I'm trying to make a simple game first.
So I have a file that contains the informations about a map, like this :
Code: Select all
001000000010
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
001000000000
Code: Select all
map = {}
for i=1,12 do
map[i] = {}
for j=1,12 do
for line in love.filesystem.lines("maps/salon.map") do
table.insert(map[i], string.sub(line,j,j))
end
end
end
The print function looks like this :
Code: Select all
x = 30
y = 30
for i=1,12 do
for j=1,12 do
love.graphics.print( {{255, 255, 255}, map[i][j]}, x,y)
x = x + 15
end
y = y + 15
x = 30
end