overloaded draw

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

overloaded draw

Post by Sparx »

Hi there: this code I am using:

love.graphics.draw(Legs[math.ceil(LegFrame[index])], x[index]-LegsTOcenterX-CameraX, y[index]-LegsTOcenterY-CameraY, 0, 1, 1)

LÖVE tells me: No matching function for overloaded draw.

or sometimes: Attempt to index field a nil value.

And few times there is no error, then the programm runs as normal...

this error appears since i added some other Tables but has nothing to do with table LegFrame...
if I just put : Legs[math.ceil(LegFrame[index])] than thiss error doesn't apper: Attempt to index field a nil value. the other not as often...

very strange and extrem frustrating.. (LegFrame[] is not empty)

[EDIT]
I just called the draw function via pcall... this one works(doesn't draw the legs the first 0.5 seconds ca...)
[/EDIT]
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: overloaded draw

Post by bartbes »

Quick list of possibilities:
  • LegFrame[index] -> nil
  • Legs[math.ceil(LegFrame[index])] -> nil
  • x[index] -> nil
  • y[index] -> nil
  • index -> nil
Try debugging them all.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: overloaded draw

Post by Sparx »

Thx , since i am new to lua i can't see these possibilities at once but guessed a few of them...

for index,content in pairs(x)

^^ this is slope so x and y will not be nill, just as index itself can't be nil
also i draw the torso the line above:
love.graphics.draw(Torso, x[index]-TorsoTOcenterX-CameraX, y[index]-TorsoTOcenterY-CameraY+15*move[index]["crouch"], 0, 1, 1)

I tried giving back the LegFrame[index]... it's allways between 0 (included) and 3 (excluded(
and Legs[1]....[3] are definded as images

i also put another variable = this Legs[math.ceil(LegFrame[index])] and this LegFrame[index] and the error is at the drawing line....
I have more problems with the draw function beeing overloaded... what does this mean?!?!
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: overloaded draw

Post by bartbes »

Sparx wrote:it's allways between 0 (included) and 3 (excluded(
and Legs[1]....[3] are definded as images
?!
If I understood correctly index can be 0, so Legs[0] can be evaluated -> nil
Sparx wrote: i also put another variable = this Legs[math.ceil(LegFrame[index])] and this LegFrame[index] and the error is at the drawing line....
I have more problems with the draw function beeing overloaded... what does this mean?!?!
That's SWIG speaking (the binding between C and lua, as used in LÖVE 0.5.0). SWIG wants to be as strict as C is, so if there's no C function defined with the arguments you supply, you get that error. In most cases means you're giving a wrong argument, which in turn means (most of the times) one of the variables/statements is nil.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: overloaded draw

Post by Sparx »

I see... this is going to be a nearly endless debuging session =(

index can be any value.. doesn't matter...
but there is no Legs[index].....

the index of Legs should be read out of the LegFrame Table ( which speifies the current animation frame as floatingpoint variable)...
index is the id of the actual player beeing drawn.

Very strange thing is that this error only happens at start of the program but not every time....

I am used to php where blocks are beeing seperated by ; which gives me the possibility to deive a single command into several lines... so the error can exactl tell me the line.....
Can i tell LÖVE or Lua or whatever to output given variables/tables on an error message or write them into a file?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: overloaded draw

Post by bartbes »

Errors: guess.. error()
Check: assert()
Output: print()
On windows you might have to look in the files stdout.txt and stderr.txt (in your LÖVE install dir).

Examples:

Code: Select all

if index > 8 then
   error("Index is too big") --gives you a blue screen with this error
end

--assert is easier for this
assert(index <= 8, "Index is too big") --First expression has to be false for the error to be run, so invert the condition

--or just output the variable
print(index)
Sparx wrote:Legs[index].....
I know.. didn't write it correctly, but I meant: Can math.ceil(LegFrame[index]) evaluate to an index not in Legs?
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: overloaded draw

Post by Sparx »

Outputing the variable is no option since they can change quite fast and the error only appears in the first 20ms after startup.

The error thing is no option to, because it errors before the real error apperas, so i never know when the real error appears..

I just tried telling the index loop to break if this one Legs[math.ceil(LegFrame[index])] is nil... everything works as expected.
Im going to try giving me en error on nil with telling me alle the vars....

Thanks so far.

[EDIT]
Now I am trying to reproduce the error but it doesn't work.... The error is simply away... it's the same code as yesterday...
Can it be, because at one startup of the computer (WInXP) I started the programm several times having a client and a server run at the same time. Both with a large number of big tables?
[/EDIT]
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests