invalid parameter expected userdata(for the nth time)

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
spider909999
Prole
Posts: 1
Joined: Thu Apr 19, 2012 7:47 pm

invalid parameter expected userdata(for the nth time)

Post 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.
User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

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

Post by trubblegum »

Don't know what's happening in char.lua, so can't comment.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

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

Post by Kadoba »

"level" needs to be a Drawable, such as an image or a canvas.

(FYI, userdata is almost always a resource)
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

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

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 12 guests