Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I get the meta table of a physics.body?

in Questions Posts: 2,020

It seems to be possible to get the meta tables for various Codea APIs. eg, getmetatable(mesh()) works fine. However, this method doesn't seem to work with APIs that require arguments. eg none of the below will even get past the compiler:

meta = getmetatable(physics.body) --later leads to "attempt to index a nil value (local 'meta')" error
meta = getmetatable(physics.body(CIRCLE,10) --later leads to "attempt to index a nil value (local 'meta')" error
meta = getmetatable(physics.body()) --"bad argument #1 to 'body' (number expected, got nil)"

Anyone know how to do this? Thank you.

Comments

  • Maybe getmetatable(physics())? I don't know, I haven't tried this, but it seems to make sense.

  • Posts: 2,020

    No, that gives the error "attempt to call a table value (global 'physics')"

  • Posts: 2,020

    I've worked it out. I was trying to establish the metamethod at compile time (ie I called the metamethod creating function from outside of setup). Box2D evidently is not online at this point, so that's why I was getting those nil values. Weird though that I could get the table for mesh. This is probably the mistake I make most often :((

Sign In or Register to comment.