Here’s my code:
kind = "circle"
shape.kind = kind
print( "kind:", kind, shape.kind )
That is the code exactly. It’s inside of other functions and if-thens, but those three lines are together, exactly like that.
Here’s the output:
kind: circle nil
What the what???
I suspect, “shape” ist not defined.
kind = "circle"
shape = {kind = kind}
print("kind:", kind, shape.kind)
It actually is defined, sorry I didn’t include that. It’s a circle created with physics.body.
Hello @UberGoober. The value returned by physics.body()
is not a Lua table, but a userdata.
myBody = physics.body(...)
myBody["kind"] = someValue -- Does nothing
Jmv38
5
Hello @ubergober. If you want to add data to a physics object shape, use the info field that way:
shape.info ={}
shape.info.kind = kind
sim
6
I believe version 1.5 will allow you to use physics bodies as tables for custom data (@john will correct me if I’m wrong).
Thank you guys. That’s really, really helpful!