Page 1 of 1

Passing a table to newPolygonShape?

Posted: Sat Sep 06, 2008 8:01 pm
by conman420
I have some code that generates co-ordinates to be passed to the polygon shape function, the code generates a table of coordinates of the map (I can't save the coordinates of the map to create the body that would just be stupid) the thing is the polygon shape doesn't accept a table and to my knowledge there is no way of converting a table into a series of arguments.

Can anyone shed any light on this?

nevermind IRC saves the day :)

There should still be an option for it to accept a table.

Re: Passing a table to newPolygonShape?

Posted: Thu Nov 12, 2009 4:51 am
by Almost
(In love 0.5,) This works for me:

points = {x1,y1,x2,y2,x3,y2}
love.graphics.polygon(type,points)

note that points is a one dimensional array.

EDIT: just realized I misread and you're talking about polygonshapes, not drawing a polygon. Still, I'm pretty sure that what I said is relevant to polygonshapes as well.

Re: Passing a table to newPolygonShape?

Posted: Thu Nov 12, 2009 7:37 am
by bartbes
For anyone wanting to know the answer:

Code: Select all

t = {1, 2, 3, "a", "b", "c"}
unpack(t) --> 1, 2, 3, "a", "b", "c"