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

Method PushModule

library/LuaTools.cpp:1021–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1019}
1020
1021bool DFHack::Lua::PushModule(color_ostream &out, lua_State *state, const char *module)
1022{
1023 AssertCoreSuspend(state);
1024
1025 // Check if it is already loaded
1026 lua_rawgetp(state, LUA_REGISTRYINDEX, &DFHACK_LOADED_TOKEN);
1027 lua_pushstring(state, module);
1028 lua_rawget(state, -2);
1029
1030 if (lua_toboolean(state, -1))
1031 {
1032 lua_remove(state, -2);
1033 return true;
1034 }
1035
1036 lua_pop(state, 2);
1037 lua_rawgetp(state, LUA_REGISTRYINDEX, &DFHACK_REQUIRE_TOKEN);
1038 lua_pushstring(state, module);
1039
1040 return Lua::SafeCall(out, state, 1, 1);
1041}
1042
1043bool DFHack::Lua::PushModulePublic(color_ostream &out, lua_State *state,
1044 const char *module, const char *name)

Callers

nothing calls this directly

Calls 6

AssertCoreSuspendFunction · 0.85
lua_rawgetpFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawgetFunction · 0.85
lua_tobooleanFunction · 0.85
SafeCallFunction · 0.85

Tested by

no test coverage detected