mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-05 18:41:05 +00:00
Simplify HUD handling in Player class
This commit is contained in:
parent
bb74b9d488
commit
36b5374715
6 changed files with 35 additions and 65 deletions
|
@ -425,15 +425,14 @@ int LuaLocalPlayer::l_hud_get_all(lua_State *L)
|
|||
return 0;
|
||||
|
||||
lua_newtable(L);
|
||||
player->hudApply([&](const std::vector<HudElement*>& hud) {
|
||||
for (std::size_t id = 0; id < hud.size(); ++id) {
|
||||
HudElement *elem = hud[id];
|
||||
if (elem != nullptr) {
|
||||
push_hud_element(L, elem);
|
||||
lua_rawseti(L, -2, id);
|
||||
}
|
||||
u32 id = 0;
|
||||
for (HudElement *elem : player->getHudElements()) {
|
||||
if (elem != nullptr) {
|
||||
push_hud_element(L, elem);
|
||||
lua_rawseti(L, -2, id);
|
||||
}
|
||||
});
|
||||
++id;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1903,15 +1903,14 @@ int ObjectRef::l_hud_get_all(lua_State *L)
|
|||
return 0;
|
||||
|
||||
lua_newtable(L);
|
||||
player->hudApply([&](const std::vector<HudElement*>& hud) {
|
||||
for (std::size_t id = 0; id < hud.size(); ++id) {
|
||||
HudElement *elem = hud[id];
|
||||
if (elem != nullptr) {
|
||||
push_hud_element(L, elem);
|
||||
lua_rawseti(L, -2, id);
|
||||
}
|
||||
u32 id = 0;
|
||||
for (HudElement *elem : player->getHudElements()) {
|
||||
if (elem != nullptr) {
|
||||
push_hud_element(L, elem);
|
||||
lua_rawseti(L, -2, id);
|
||||
}
|
||||
});
|
||||
++id;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue