diff --git a/doc/ru/scripting/builtins/libhud.md b/doc/ru/scripting/builtins/libhud.md index 5c1696ef7..bad0e93c6 100644 --- a/doc/ru/scripting/builtins/libhud.md +++ b/doc/ru/scripting/builtins/libhud.md @@ -73,6 +73,9 @@ hud.is_paused() -> boolean -- Возвращает true если открыт инвентарь или оверлей. hud.is_inventory_open() -> boolean +-- Возвращает true если открыт инвентарь игрока. +hud.is_player_inventory_open() -> boolean + -- Устанавливает разрешение на паузу. При значении false меню паузы не приостанавливает игру. hud.set_allow_pause(flag: boolean) diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index c5c1352cb..fee9ff192 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -688,6 +688,10 @@ bool Hud::isInventoryOpen() const { return inventoryOpen; } +bool Hud::isPlayerInventoryOpen() const { + return inventoryView != nullptr; +} + bool Hud::isPause() const { return pause; } diff --git a/src/frontend/hud.hpp b/src/frontend/hud.hpp index dc0a35666..f80c36369 100644 --- a/src/frontend/hud.hpp +++ b/src/frontend/hud.hpp @@ -147,6 +147,8 @@ public: /// @brief Check if inventory mode on bool isInventoryOpen() const; + bool isPlayerInventoryOpen() const; + /// @brief Check if pause mode on bool isPause() const; diff --git a/src/logic/scripting/lua/libs/libhud.cpp b/src/logic/scripting/lua/libs/libhud.cpp index a65acb170..7f5c893c5 100644 --- a/src/logic/scripting/lua/libs/libhud.cpp +++ b/src/logic/scripting/lua/libs/libhud.cpp @@ -162,6 +162,10 @@ static int l_is_inventory_open(lua::State* L) { return lua::pushboolean(L, hud->isInventoryOpen()); } +static int l_is_player_inventory_open(lua::State* L) { + return lua::pushboolean(L, hud->isPlayerInventoryOpen()); +} + static int l_is_content_access(lua::State* L) { return lua::pushboolean(L, hud->isContentAccess()); } @@ -217,6 +221,7 @@ const luaL_Reg hudlib[] = { {"resume", wrap_hud}, {"is_paused", wrap_hud}, {"is_inventory_open", wrap_hud}, + {"is_player_inventory_open", wrap_hud}, {"get_player", wrap_hud}, {"_is_content_access", wrap_hud}, {"_set_content_access", wrap_hud},