I am little newbie in C++ scripting but I know some things.
I'm compiling a plugin that use a function to call an Lua callback using the LuaBind, but the client crashes when function doesn't exists on main.lua
, also I'm trying to add an error handler to that functions... I don't know what I can do to solve it.
Here is my code:
{
try
{
luabind::call_function<int>(L, "onServerFrame", elapsedTime);
}
catch (luabind::error& e)
{
std::string error = lua_tostring(e.state(), -1);
std::cout << error << "\n";
}
}
Solved. Thanks to my friend habi.
luabind::object func = g[name];
if( func ) { if( luabind::type(func) == LUA_TFUNCTION ) luabind::call_function<void>(L,"onServerFrame", elapsedTime);}