MCPcopy Create free account
hub / github.com/DFHack/dfhack / SafeCall

Method SafeCall

library/LuaTools.cpp:813–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

811}
812
813bool DFHack::Lua::SafeCall(color_ostream &out, lua_State *L, int nargs, int nres, bool perr)
814{
815 AssertCoreSuspend(L);
816
817 int base = lua_gettop(L) - nargs;
818
819 color_ostream *cur_out = Lua::GetOutput(L);
820 set_dfhack_output(L, &out);
821
822 lua_pushcfunction(L, dfhack_onerror);
823 lua_insert(L, base);
824
825 bool ok = lua_pcall(L, nargs, nres, base) == LUA_OK;
826
827 if (!ok && perr)
828 report_error(L, &out, true);
829
830 lua_remove(L, base);
831 set_dfhack_output(L, cur_out);
832
833 return ok;
834}
835
836bool DFHack::Lua::CallLuaModuleFunction(color_ostream &out, lua_State *L,
837 const char *module_name, const char *fn_name,

Callers

nothing calls this directly

Calls 4

AssertCoreSuspendFunction · 0.85
lua_gettopFunction · 0.85
set_dfhack_outputFunction · 0.85
report_errorFunction · 0.85

Tested by

no test coverage detected