Load Raw Text Files [Resolved]
Posted: Thu Jun 14, 2012 4:25 pm
I'm pretty new to LUA and of course, to LÖVE, but not new to programming at all. What I can't find out is why I still can't load a raw text file...
I've used the Lua IO, the love.filesystem and all, but still can't make it work...
Any help would be greatly appreciated
Here's my latest code, just in case:
(The foo.txt exists inside the directory, yes, and it has "Hello world!" inside)
I've used the Lua IO, the love.filesystem and all, but still can't make it work...
Any help would be greatly appreciated
Here's my latest code, just in case:
Code: Select all
function love.load()
love.graphics.setBackgroundColor(255,255,255)
fontie = love.graphics.newFont(12)
love.graphics.setFont(fontie)
file = love.filesystem.newFile("foo.txt")
s = file:read()
file:close()
end
function love.draw()
love.graphics.setColor(255,255,255,255)
love.graphics.print(typeof(s),100,100)
end
function typeof(var)
local _type = type(var);
if(_type ~= "table" and _type ~= "userdata") then
return _type;
end
local _meta = getmetatable(var);
if(_meta ~= nil and _meta._NAME ~= nil) then
return _meta._NAME;
else
return _type;
end
end