Page 1 of 1

[SOLVED] Incorrect parameter type: expected userdata.

Posted: Sat Apr 20, 2013 1:17 am
by cyclone42
I just started with LÖVE, so this is basic.
I am just trying to make a draggable pie, but I keep getting this error:

Code: Select all

Error
main.lua:33: Incorrect paremeter type: expected userdata.
Traceback
[C]: in function 'draw'
main.lua:33: in function 'draw'
[C]: in function 'xpcall'
Can someone please tell me why I am getting this error?

Re: Incorrect parameter type: expected userdata.

Posted: Sat Apr 20, 2013 6:52 am
by micha
In line 33 of your code you are trying to draw the pie. The love.graphics.draw() function expects a drawable object. In your case you want to draw an Image. But what you do is call

Code: Select all

love.graphics.draw(pie, imgx, imgy)
This does not work, because pie is not an image. pie is a table with data about the pie.

To make it run, you first need to store the pie image, somewhere, so replace your third line of the code by

Code: Select all

image = love.graphics.newImage("pie.png"),
(You forgot the "image = ")
Now the image is stored as pie.image. And you can replace the drawing function call by this:

Code: Select all

love.graphics.draw(pie.image, imgx, imgy)

Re: Incorrect parameter type: expected userdata.

Posted: Sat Apr 20, 2013 11:49 am
by cyclone42
Thank you. That fixed it.