2

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";
    }
}
Nifim
  • 4,758
  • 2
  • 12
  • 31
mazda7
  • 31
  • 4
  • I wouldn't recommend Lua for a beginner to the scripting world. You should look into AngelScript, it's a lot easier to bind. – veridis_quo_t Sep 22 '20 at 01:21

1 Answers1

1

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);}
mazda7
  • 31
  • 4