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

Function internal_listCommands

library/LuaApi.cpp:4186–4208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4184}
4185
4186static int internal_listCommands(lua_State *L)
4187{
4188 auto plugins = Core::getInstance().getPluginManager();
4189
4190 const char *name = luaL_checkstring(L, 1);
4191
4192 auto plugin = plugins->getPluginByName(name);
4193 if (!plugin)
4194 {
4195 lua_pushnil(L);
4196 return 1;
4197 }
4198
4199 size_t num_commands = plugin->size();
4200 lua_newtable(L);
4201 for (size_t i = 0; i < num_commands; ++i)
4202 {
4203 lua_pushinteger(L, i + 1);
4204 lua_pushstring(L, (*plugin)[i].name.c_str());
4205 lua_settable(L, -3);
4206 }
4207 return 1;
4208}
4209
4210static const PluginCommand * getPluginCommand(const char * command)
4211{

Callers

nothing calls this directly

Calls 6

lua_pushnilFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushstringFunction · 0.85
lua_settableFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected