lua-users home
lua-l archive

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

I have no idea why my C++ code does not evaluate global_objects.effectype.water
as a table. Should I actauly need to separate global_objects effectype and water
and explicitly do the table traverse?

I don't think lua_getglobal handles the entire 'path' for you.

You need to do a lua_getglobal on "global_objects" and then access the result table using lua_gettable. This way you'll find the "effectype" [only 1 't'?] table and can call lua_gettable again to get to the "water" table.

Best check the reference manual for more details.

Also, doing type-checking on results is good, but it looks like checking for nil after you've ensured it's a table is a bit redundant.

I hope this helps.

no signature is a signature.