Give the online lua mainmenu also the client_list and mods (#8691)

master
Lejo 2020-05-01 16:47:17 +02:00 committed by GitHub
parent 3f275d799c
commit 74d9b6010f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 36 deletions

View File

@ -167,7 +167,10 @@ core.get_favorites(location) -> list of favorites (possible in async calls)
name = <server name/nil>,
address = <address of server/nil>,
port = <port>
clients_list = <array of clients/nil>
mods = <array of mods/nil>
},
...
}
core.delete_favorite(id, location) -> success

View File

@ -406,6 +406,37 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
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);
index++;
}