add hud.is_paused and hud.is_inventory_open
This commit is contained in:
parent
7487c55e0c
commit
adabe781c5
@ -571,6 +571,18 @@ hud.resume()
|
|||||||
|
|
||||||
Closes the pause menu.
|
Closes the pause menu.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hud.is_paused() -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns true if pause menu is open.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hud.is_inventory_open() -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns true if inventory is open or overlay is shown.
|
||||||
|
|
||||||
### *time* library
|
### *time* library
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
@ -582,6 +582,18 @@ hud.resume()
|
|||||||
|
|
||||||
Закрывает меню паузы.
|
Закрывает меню паузы.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hud.is_paused() -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Возвращает true если открыто меню паузы.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hud.is_inventory_open() -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Возвращает true если открыт инвентарь или оверлей.
|
||||||
|
|
||||||
## Библиотека time
|
## Библиотека time
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
@ -3,6 +3,9 @@ local DROP_INIT_VEL = {0, 3, 0}
|
|||||||
|
|
||||||
function on_hud_open()
|
function on_hud_open()
|
||||||
input.add_callback("player.drop", function ()
|
input.add_callback("player.drop", function ()
|
||||||
|
if hud.is_paused() or hud.is_inventory_open() then
|
||||||
|
return
|
||||||
|
end
|
||||||
local pid = hud.get_player()
|
local pid = hud.get_player()
|
||||||
local invid, slot = player.get_inventory(pid)
|
local invid, slot = player.get_inventory(pid)
|
||||||
local itemid, itemcount = inventory.get(invid, slot)
|
local itemid, itemcount = inventory.get(invid, slot)
|
||||||
|
|||||||
@ -124,6 +124,14 @@ static int l_hud_get_player(lua::State* L) {
|
|||||||
return lua::pushinteger(L, player->getId());
|
return lua::pushinteger(L, player->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_hud_is_paused(lua::State* L) {
|
||||||
|
return lua::pushboolean(L, hud->isPause());
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_hud_is_inventory_open(lua::State* L) {
|
||||||
|
return lua::pushboolean(L, hud->isInventoryOpen());
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg hudlib [] = {
|
const luaL_Reg hudlib [] = {
|
||||||
{"open_inventory", lua::wrap<l_hud_open_inventory>},
|
{"open_inventory", lua::wrap<l_hud_open_inventory>},
|
||||||
{"close_inventory", lua::wrap<l_hud_close_inventory>},
|
{"close_inventory", lua::wrap<l_hud_close_inventory>},
|
||||||
@ -134,6 +142,8 @@ const luaL_Reg hudlib [] = {
|
|||||||
{"close", lua::wrap<l_hud_close>},
|
{"close", lua::wrap<l_hud_close>},
|
||||||
{"pause", lua::wrap<l_hud_pause>},
|
{"pause", lua::wrap<l_hud_pause>},
|
||||||
{"resume", lua::wrap<l_hud_resume>},
|
{"resume", lua::wrap<l_hud_resume>},
|
||||||
|
{"is_paused", lua::wrap<l_hud_is_paused>},
|
||||||
|
{"is_inventory_open", lua::wrap<l_hud_is_inventory_open>},
|
||||||
{"get_player", lua::wrap<l_hud_get_player>},
|
{"get_player", lua::wrap<l_hud_get_player>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user