mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
added hud.get_second_inventory
This commit is contained in:
parent
2cec6c3f9a
commit
cb1b113181
4 changed files with 25 additions and 0 deletions
|
|
@ -55,6 +55,9 @@ hud.close(layoutid: string)
|
|||
-- Дает ID инвентаря открытого блока или 0.
|
||||
hud.get_block_inventory() -> int
|
||||
|
||||
-- Дает ID второго открытого инвентаря (блок, виртуальный инвентарь...) или 0.
|
||||
hud.get_second_inventory() -> int
|
||||
|
||||
-- Дает ID игрока, к которому привязан пользовательский интерфейс.
|
||||
hud.get_player() -> int
|
||||
|
||||
|
|
|
|||
|
|
@ -725,6 +725,16 @@ std::shared_ptr<Inventory> Hud::getBlockInventory() {
|
|||
return blockUI->getInventory();
|
||||
}
|
||||
|
||||
std::shared_ptr<Inventory> Hud::getSecondInventory() {
|
||||
if (blockUI) {
|
||||
return blockUI->getInventory();
|
||||
}
|
||||
if (secondInvView) {
|
||||
return secondInvView->getInventory();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Hud::isContentAccess() const {
|
||||
return showContentPanel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,6 +203,8 @@ public:
|
|||
|
||||
std::shared_ptr<Inventory> getBlockInventory();
|
||||
|
||||
std::shared_ptr<Inventory> getSecondInventory();
|
||||
|
||||
bool isContentAccess() const;
|
||||
|
||||
void setContentAccess(bool flag);
|
||||
|
|
|
|||
|
|
@ -140,6 +140,15 @@ static int l_get_block_inventory(lua::State* L) {
|
|||
}
|
||||
}
|
||||
|
||||
static int l_get_second_inventory(lua::State* L) {
|
||||
auto inventory = hud->getSecondInventory();
|
||||
if (inventory == nullptr) {
|
||||
return lua::pushinteger(L, 0);
|
||||
} else {
|
||||
return lua::pushinteger(L, inventory->getId());
|
||||
}
|
||||
}
|
||||
|
||||
static int l_get_player(lua::State* L) {
|
||||
auto player = hud->getPlayer();
|
||||
return lua::pushinteger(L, player->getId());
|
||||
|
|
@ -202,6 +211,7 @@ const luaL_Reg hudlib[] = {
|
|||
{"open_permanent", wrap_hud<l_open_permanent>},
|
||||
{"show_overlay", wrap_hud<l_show_overlay>},
|
||||
{"get_block_inventory", wrap_hud<l_get_block_inventory>},
|
||||
{"get_second_inventory", wrap_hud<l_get_second_inventory>},
|
||||
{"close", wrap_hud<l_close>},
|
||||
{"pause", wrap_hud<l_pause>},
|
||||
{"resume", wrap_hud<l_resume>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue