Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int LuaShell::TimedCall(lua_State* L)
- {
- luaL_argcheck(L, lua_type(L, 1) == LUA_TFUNCTION, 1, "setTimeout requires a function.");
- double timeout = luaL_checknumber(L, 2);
- lua_State* globalL = lua_getstate(L);
- RegValue v = lua_toregvalue(L, -1);
- TimeManager::getSingleton().SetTimeout([globalL, v](double t)->double {
- try
- {
- lua_pushregvalue(globalL, v);
- return lua_tcall<double, double>(globalL, t);
- }
- catch (const std::exception& ex)
- {
- // log something.
- return -1;
- }
- }, timeout);
- return 0;
- }
Add Comment
Please, Sign In to add comment