Hello! I've created a simple mapeditor for a game I am making. It's just a array/list/table or whatever it's called within another, the index of the first indicating the x coordinate and the one within the y coordinate, and the value is the type of tile.
This is saved to a file, in which every 32 lines represents the content of the "outer" array, each of the lines have 20 numbers seperated by spaces.
Now I want to open this file in the game and asign it to an array again like this:
map = {}
i = 1
file = io.open("/Users/linlin/LÖVE/Game2/map.txt", "r")
for line in file:lines() do
map[i] = {}
map[i] = split(lista, " ")
i = i + 1
end
file.close()
but the game crashes with the text: "attempt to call global 'split' ( a nil value )"
Still can't get it to work :/
And trying to figure out what's wrong is a nightmare when I can't print the variables.
Is there any way to bring up the a console to which I can print stuff? I'm on OSX, and i think i read somewhere around here that it only worked on Windows... Is that correct?
Thank you! I got it to work, it was pretty easy once I got a way to debug it
The problem was that I forgot to make the strings into numbers after loading them.
Yeah i made my own split function after looking at some examples online, I've studied python so I'm used to that function.