| 811 | } |
| 812 | |
| 813 | bool 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 | |
| 836 | bool DFHack::Lua::CallLuaModuleFunction(color_ostream &out, lua_State *L, |
| 837 | const char *module_name, const char *fn_name, |
nothing calls this directly
no test coverage detected