Please Help, THis error is driving me Insane!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Please Help, THis error is driving me Insane!

Post by Neverfly »

I keep getting this error:
ERROR! No Matching Function for Overloaded draw

Stack Traceback:
[C:] in Function 'draw'
main.lua:40: in function main.lua:38

And I have NO clue what this means.
Heres the Code:

Code: Select all

function load()
Font = love.graphics.newFont(love.default_font, 20)
love.graphics.setFont(Font)
Tab = {}
Message = "Marlowe"
Number, ENumber = 200,300

for x = 1, string.len(Message) do
table.insert(Tab, {})
table.insert(Tab[1], string.sub(Message, x, x))
end

for i,v in ipairs(Tab) do

if (i == 1) then
v[1] = Number
v[2] = ENumber
v[3] = math.random(1,360)
else
v[1] = Tab[i - 1][1] + 20
v[2] = ENumber
v[3] = math.random(1,360)
end
end

end

function update()
for i,v in ipairs(Tab) do
v[3] = v[3] + 1
if (v[3] >= 360) then
v[3] = 0
end
end
end

function draw()
for i,v in ipairs(Tab) do
love.graphics.draw(v, v[1], v[2], v[3])
end
end


Help? :cry:
lynerd
Prole
Posts: 4
Joined: Sat Jun 06, 2009 9:02 pm

Re: Please Help, THis error is driving me Insane!

Post by lynerd »

Is it because you have your draw method with 4 parameters instead of 3? Shouldn't it only be love.graphics.draw("what to draw", x, y)?

Code: Select all

love.graphics.draw(v, v[1], v[2], v[3])
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Re: Please Help, THis error is driving me Insane!

Post by Neverfly »

Nah, the 4th Parameter is the Rotation Angle.

Try:

game.graphics.draw("Some Text", 200, 300, 90)

That will Rotate "Some Text" By 90 Degrees
lynerd
Prole
Posts: 4
Joined: Sat Jun 06, 2009 9:02 pm

Re: Please Help, THis error is driving me Insane!

Post by lynerd »

Maybe one of the parameters is not passing as the right type? Like v isn't working as a string or v[1], v[2], or v[3] isn't passing as a number?
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Re: Please Help, THis error is driving me Insane!

Post by Neverfly »

No Clue, But I've gotten this error on more than one occasion, and I have no clue how to fix it.
User avatar
Star Crunch
Prole
Posts: 33
Joined: Sun Feb 15, 2009 12:13 am
Location: Monterrey, MX
Contact:

Re: Please Help, THis error is driving me Insane!

Post by Star Crunch »

You're passing a table, v, as the first argument to draw, whereas I'm guessing you want a string.

If you pass Tab[1] instead, you should get something like: 200*, 300, a rapidly changing number
between 1 and 360, and then "lowe", all spinning really fast.

If you want "Marlowe", you would do something like (note: all untested)

Code: Select all

table.insert(Tab[x], string.sub(Message, x, x))
and then move your other indices up by one, i.e.

Code: Select all

if (i == 1) then
v[2] = Number
v[3] = ENumber
v[4] = math.random(1,360)
else
v[2] = Tab[i - 1][2] + 20
v[3] = ENumber
v[4] = math.random(1,360)
end
and

Code: Select all

love.graphics.draw(v[1], v[2], v[3], v[4])
* - I just checked, and draw() does treat numbers as strings.
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Re: Please Help, THis error is driving me Insane!

Post by Neverfly »

BEASTLY!

Thanks dude, you were right, I was passing the wrong stuff in draw.
It works perfectly now
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 63 guests