2
votes

I have some code using Luabind, and I need to execute a function (from C++) if it's present in the _G table, but otherwise do nothing. How do I detect if a function is present in _G or not?

1

1 Answers

3
votes

Something like this should work:

if (luabind::object f = luabind::globals(L)["f"])
{
    f(...);
}