Page 1 of 1

Loading Images

Posted: Fri Mar 19, 2010 12:52 am
by CrystalMoth
function love.load()
pic1 = love.graphics.newImage(pic1.bmp)
end

function love.draw()
love.graphics.draw(pic1, 50, 50, 0, 0, 0, 0, 0)
end


the above is my code but it just gives me this erro:

Error
main.lua.7 attempt to index global 'pic1' a nil value
Traceback:
manin.lua.7: in function 'load'
[C:] in function 'xpcall'

Re: Loading Images

Posted: Fri Mar 19, 2010 1:12 am
by hatingcollege
On this line:

Code: Select all

pic1 = love.graphics.newImage(pic1.bmp)
You're forgetting to enclose your strings with quotes. Lua thinks you're trying to access the bmp index of pic1 (as if it were a table).

Fix:

Code: Select all

pic1 = love.graphics.newImage('pic1.bmp')