Reading a variable from a file using filesystem
Posted: Thu Sep 05, 2013 8:07 pm
Hey guys,
I'm currently trying to make a program that will write '12' to 'test.lua', then print a variable that equals the number in the file. For instance,
But every time I run it, I get the error "testing lua1, unexpected symbol near '12'.
I've opened the file to check it out, the file says '12'. That's it. Just 12.
I've checked the forums for this problem, and other parts of the internet, but have not found a solution.
Thank you.
I'm currently trying to make a program that will write '12' to 'test.lua', then print a variable that equals the number in the file. For instance,
Code: Select all
function love.load()
number = {}
local file = love.filesystem.newFile("testing.lua")
love.filesystem.write("testing.lua", "12")
number.y = love.filesystem.load('testing.lua')()
end
function love.draw()
love.graphics.print(number.y, 200, 200)
end
I've opened the file to check it out, the file says '12'. That's it. Just 12.
I've checked the forums for this problem, and other parts of the internet, but have not found a solution.
Thank you.