lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!

2009/5/31 Ivo Beltchev <ivo@roadrunner.com>:

> I am embedding Lua in my application and I want to expose some objects to
> the Lua scripts. Different objects have different sets of properties. For
> example object1 can have speed and length and object2 can have mass and
> friction.
>
> Currently if the script wants to check if an object has mass>20 it has to
> do:
>
> if (obj.mass and obj.mass>20)...

Personally, I like "cumbersome" code very much. To the reader, it
clearly tells what you want to do (check if the object has a property
"mass" and if it has, compare it).

Regards,
Matthias