Page 1 of 1

Please Help, THis error is driving me Insane!

Posted: Sat Jun 06, 2009 11:28 pm
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:

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

Posted: Sun Jun 07, 2009 12:06 am
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])

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

Posted: Sun Jun 07, 2009 12:11 am
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

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

Posted: Sun Jun 07, 2009 12:15 am
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?

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

Posted: Sun Jun 07, 2009 12:42 am
by Neverfly
No Clue, But I've gotten this error on more than one occasion, and I have no clue how to fix it.

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

Posted: Sun Jun 07, 2009 1:26 am
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.

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

Posted: Sun Jun 07, 2009 10:38 pm
by Neverfly
BEASTLY!

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