Lua - Reflection - Get list of functions/fields on an object?

luanoob picture luanoob · Apr 12, 2010 · Viewed 36.4k times · Source

I'm new to Lua and dealing with Lua as a scripting language in an alpha release of a program. The developer is unresponsive and I need to get a list of functions provided by some C++ objects which are accessible from the Lua code.

Is there any easy way to see what fields and functions these objects expose?

Answer

Frank Schwieterman picture Frank Schwieterman · Apr 12, 2010

In Lua, to view the members of a object, you can use:

for key,value in pairs(o) do
    print("found member " .. key);
end

Unfortunately I don't know if this will work for objects imported from C++.