I cannot seem to recall how to create custom properties. Does anyone have any insight?
Something like:
object.isActive
object.isOff
object.isFlying
Am I missing something? [import]uid: 73951 topic_id: 26073 reply_id: 326073[/import]
I cannot seem to recall how to create custom properties. Does anyone have any insight?
Something like:
object.isActive
object.isOff
object.isFlying
Am I missing something? [import]uid: 73951 topic_id: 26073 reply_id: 326073[/import]
You just do it.
if object.isActive then
–do one thing
else
–do another thing
end[/lua]
Edit:
I suppose I should clarify that this works for tables and things that more or less behave like tables (such as Corona display objects), not numbers or strings because they’re not objects in the classic sense.
So the following doesn’t work
[lua]local object = “A string”
object.isActive = true[/lua]
It’s not so much that you’re adding ‘properties’ to an ‘object’ in Lua. You add ‘key’/‘value’ pairs to a ‘table’. [import]uid: 44647 topic_id: 26073 reply_id: 105557[/import]
Thanks toby2. I just had a mental block. Thanks for clearing it up! [import]uid: 73951 topic_id: 26073 reply_id: 105583[/import]