Page 1 of 1

invalid parameter expected userdata(for the nth time)

Posted: Thu Apr 19, 2012 7:51 pm
by spider909999
I know there have been allot of these topics, but each one seems to have different solution and so far none have resolved the titular error. the code is as follows:

Code: Select all

goingright = true
spawnx = 100
spawny = 400
function love.load()
	char = love.graphics.newImage("char.png")
	charl = love.graphics.newImage("charl.png")
	level = love.graphics.newImage("level.png")
		x = 0
		y = 0
end

function love.draw()
	love.graphics.draw(level, x, y)
	if not goingright then 
		love.graphics.draw(charl, chart.charx, chart.chary)
	else
		love.graphics.draw(char, chart.charx, chart.chary)
	end
end

dofile("char.lua")
The error is at line 13 where the level background placeholder is drawn. Any ideas would be very useful, as this is seriously hindering me making any further progress on this project.

Re: invalid parameter expected userdata(for the nth time)

Posted: Thu Apr 19, 2012 9:08 pm
by trubblegum
Don't know what's happening in char.lua, so can't comment.

Re: invalid parameter expected userdata(for the nth time)

Posted: Thu Apr 19, 2012 9:18 pm
by Kadoba
"level" needs to be a Drawable, such as an image or a canvas.

(FYI, userdata is almost always a resource)

Re: invalid parameter expected userdata(for the nth time)

Posted: Thu Apr 19, 2012 9:22 pm
by dreadkillz
Your code works for me when I deleted your dofile. There's most certainly something wrong with your char.lua. Also you are calling your chart table in your love.graphics.draw, but I don't see it declared anywhere.

Re: invalid parameter expected userdata(for the nth time)

Posted: Fri Apr 20, 2012 9:28 am
by Robin
Also see The Rules: if you don't attach a .love, we probably can't help you.

In this case, you probably did something like "level = ..." in char.lua, like the others said. Other times, it will probably not be so easy to help you without .love.