Page 2 of 2

Re: Referencing object functions?

Posted: Sun Feb 25, 2018 2:18 pm
by grump
ivan wrote: Sun Feb 25, 2018 1:30 pmPS. Hope you don't mind, but I've added your nickname to the game's end credits.
Not at all, thanks.

Re: Referencing object functions?

Posted: Tue Feb 27, 2018 10:37 am
by coffeecat
I'm not sure why you need Body_getPosition, but if you only need a semantically equivalent function, you can use a simple wrapper:

Code: Select all

local function Body_getPosition(body)
  return body:getPosition()
end

Re: Referencing object functions?

Posted: Tue Feb 27, 2018 4:03 pm
by ivan
I'm porting a game that uses a slightly different API for Box2D so it's kind of useful to add/modify the functions for Bodies,Joints, etc.
Like for example, contact:getOther is quite useful but love.physics doesn't include that function.
Also, with the getregistry technique, you can get a direct reference to the functions, (circumventing metatables), which is x0.85 faster in LuaJIT and considerably faster than plain Lua.
Not a big deal but might come in handy if you like to squeeze every last drop of performance.