[SOLVED] Incorrect parameter type: expected userdata.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cyclone42
Prole
Posts: 2
Joined: Sat Apr 20, 2013 12:59 am

[SOLVED] Incorrect parameter type: expected userdata.

Post 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?
Attachments
MovePie.love
(24.95 KiB) Downloaded 155 times
Last edited by cyclone42 on Sat Apr 20, 2013 11:54 am, edited 1 time in total.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Incorrect parameter type: expected userdata.

Post 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)
cyclone42
Prole
Posts: 2
Joined: Sat Apr 20, 2013 12:59 am

Re: Incorrect parameter type: expected userdata.

Post by cyclone42 »

Thank you. That fixed it.
Post Reply

Who is online

Users browsing this forum: Awarre, Google [Bot] and 2 guests