Hej,
I am 1 week into Corona and I am absolutely loving it, everything works like a charm.
But today I got a question and it seems that it is not really possible, but before I throw away all my code I just wanted to ask, whether someone knows anything about eval a string.
So i tried to write a saveToFile module which i could call like this : saveToFile ( { “obj.x” , “200” } )
function saveToFile ( thisTable )
local path = system.pathForFile( “data.txt”, system.DocumentsDirectory )
local file = io.open( path, “w+b” )
local writeString = ("""…thisTable[1]…"", "…thisTable[2])
end
file:write( writeString )
io.close( file )
writeTable = nil
writeString = nil
end
So it writes everything to a file and it’s great, I am having great fun. But when I try to resume the game and set the obj to its previously stored position I dont quite can figure out how to get it to work.
My attempt was:
eval ( thisTable[i]…"="… thisTable[i+1])
but since eval is not working in corona I am stuck.
If maybe someone knows the answere, I would be very delighted.
Thank you
Philip
