It might be good to document that getPoints does not return a table.
If this is a common convention in the Love API perhaps an explicit technique would be better.
getPoints pushes values onto stack
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: getPoints pushes values onto stack
Yes, this allows you to pass the values directly to love.graphics.polygon.
- BlackNecro
- Prole
- Posts: 2
- Joined: Fri Aug 29, 2008 2:09 pm
Re: getPoints pushes values onto stack
Wouldn't a table be easier to handle and if you would want to pass it to the polygon function just use love.graphics.polygon(drawtype,unpack(pointtable))?
Re: getPoints pushes values onto stack
Well ... I guess, if enough people think so.
My reasoning was that it would be much slower to construct a table and unpacking it again before sending it to love.graphics.polygon. You can still pack the values:
We could add p:getPointsTable(), and enjoy BOTH variants.
My reasoning was that it would be much slower to construct a table and unpacking it again before sending it to love.graphics.polygon. You can still pack the values:
Code: Select all
t = { p:getPoints() }
Re: getPoints pushes values onto stack
EDIT: Removed. Didn't pay attention to previous code:
This is good. Maybe the name "getPoints" is a problem though, particularly if there are more like this.
For the record, an array userdata may be a solution for future table<->array interop dilemmas.
The book uses exactly that for its userdata examples: http://www.lua.org/pil/28.1.html
Code: Select all
t = { p:getPoints() }
For the record, an array userdata may be a solution for future table<->array interop dilemmas.
The book uses exactly that for its userdata examples: http://www.lua.org/pil/28.1.html
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests