forked from Mirrorlandia_minetest/minetest
Give the online lua mainmenu also the client_list and mods (#8691)
This commit is contained in:
parent
3f275d799c
commit
74d9b6010f
@ -167,7 +167,10 @@ core.get_favorites(location) -> list of favorites (possible in async calls)
|
|||||||
name = <server name/nil>,
|
name = <server name/nil>,
|
||||||
address = <address of server/nil>,
|
address = <address of server/nil>,
|
||||||
port = <port>
|
port = <port>
|
||||||
|
clients_list = <array of clients/nil>
|
||||||
|
mods = <array of mods/nil>
|
||||||
},
|
},
|
||||||
|
...
|
||||||
}
|
}
|
||||||
core.delete_favorite(id, location) -> success
|
core.delete_favorite(id, location) -> success
|
||||||
|
|
||||||
|
@ -406,6 +406,37 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
|
|||||||
lua_settable(L, top_lvl2);
|
lua_settable(L, top_lvl2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server["clients_list"].isArray()) {
|
||||||
|
unsigned int index_lvl2 = 1;
|
||||||
|
lua_pushstring(L, "clients_list");
|
||||||
|
lua_newtable(L);
|
||||||
|
int top_lvl3 = lua_gettop(L);
|
||||||
|
for (const Json::Value &client : server["clients_list"]) {
|
||||||
|
lua_pushnumber(L, index_lvl2);
|
||||||
|
std::string topush = client.asString();
|
||||||
|
lua_pushstring(L, topush.c_str());
|
||||||
|
lua_settable(L, top_lvl3);
|
||||||
|
index_lvl2++;
|
||||||
|
}
|
||||||
|
lua_settable(L, top_lvl2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server["mods"].isArray()) {
|
||||||
|
unsigned int index_lvl2 = 1;
|
||||||
|
lua_pushstring(L, "mods");
|
||||||
|
lua_newtable(L);
|
||||||
|
int top_lvl3 = lua_gettop(L);
|
||||||
|
for (const Json::Value &mod : server["mods"]) {
|
||||||
|
|
||||||
|
lua_pushnumber(L, index_lvl2);
|
||||||
|
std::string topush = mod.asString();
|
||||||
|
lua_pushstring(L, topush.c_str());
|
||||||
|
lua_settable(L, top_lvl3);
|
||||||
|
index_lvl2++;
|
||||||
|
}
|
||||||
|
lua_settable(L, top_lvl2);
|
||||||
|
}
|
||||||
|
|
||||||
lua_settable(L, top);
|
lua_settable(L, top);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user