mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 10:29:47 +00:00
Merge pull request #1043 from ostermine/feat/hotbar-control
make hotbar size and layout configurable
This commit is contained in:
commit
bb73e3f354
16 changed files with 188 additions and 20 deletions
|
|
@ -82,6 +82,12 @@ hud.is_player_inventory_open() -> boolean
|
|||
-- Sets whether to allow pausing. If false, the pause menu will not pause the game.
|
||||
hud.set_allow_pause(flag: bool)
|
||||
|
||||
-- Returns true if the hotbar is not hidden with hud.set_hotbar_visible.
|
||||
hud.is_hotbar_visible() -> bool
|
||||
|
||||
-- Shows or hides the hotbar. Selecting a slot with the mouse wheel and number keys keeps working.
|
||||
hud.set_hotbar_visible(flag: bool)
|
||||
|
||||
-- Function that controls the named skeleton 'hand' (see gfx.skeletons)
|
||||
hud.hand_controller: function()
|
||||
```
|
||||
|
|
|
|||
|
|
@ -142,7 +142,14 @@ Switches the player's camera. See [cameras](libcameras.md).
|
|||
player.set_selected_slot(playerid: int, slotid: int)
|
||||
```
|
||||
|
||||
Sets the selected slot index
|
||||
Sets the selected slot index. The index wraps around the hotbar size.
|
||||
|
||||
```lua
|
||||
player.get_hotbar_size(playerid: int) -> int
|
||||
player.set_hotbar_size(playerid: int, size: int)
|
||||
```
|
||||
|
||||
Hotbar size getter and setter: the number of first player inventory slots that can be selected. `player.set_selected_slot` wraps the index by it, and the selected slot is moved into the range when the size decreases. Default value is `hotbar-size` from `config/defaults.toml` (10); the value is not saved with the world. On the client these slots are shown in the hotbar and selected with the mouse wheel and number keys.
|
||||
|
||||
```lua
|
||||
player.get_selected_block(playerid: int) -> x,y,z
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ Element is a container. Does not have specific attributes.
|
|||
> [!WARNING]
|
||||
> Slots not linked to an inventory will not be displayed. "Linked to an inventory" refers to the association between an inventory UI element and an inventory via an ID. This link can be explicitly established using `inventory_ui.inventory = inventory_id`. [(see ui.md)](scripting/ui.md#inventory)
|
||||
|
||||
A pack can replace the player inventory screen and the hotbar with its own layouts using `inventory-layout` (`"core:inventory"` by default) and `hotbar-layout` in `config/defaults.toml`. The root element of such a layout must be `inventory`, it is bound to the player inventory. The hotbar layout is placed at the bottom center of the screen unless it has `position-func`.
|
||||
|
||||
## *slot*
|
||||
|
||||
Element must be a direct sub-element of *inventory*.
|
||||
|
|
|
|||
|
|
@ -84,6 +84,12 @@ hud.is_player_inventory_open() -> boolean
|
|||
-- Устанавливает разрешение на паузу. При значении false меню паузы не приостанавливает игру.
|
||||
hud.set_allow_pause(flag: boolean)
|
||||
|
||||
-- Возвращает true, если хотбар не скрыт через hud.set_hotbar_visible.
|
||||
hud.is_hotbar_visible() -> boolean
|
||||
|
||||
-- Показывает или скрывает хотбар. Выбор слота колесом мыши и цифровыми клавишами продолжает работать.
|
||||
hud.set_hotbar_visible(flag: boolean)
|
||||
|
||||
-- Функция, управляющая именованным скелетом 'hand' (см. gfx.skeletons)
|
||||
hud.hand_controller: function()
|
||||
```
|
||||
|
|
|
|||
|
|
@ -95,9 +95,17 @@ player.get_interaction_distance(playerid: int) -> number
|
|||
-- Возвращает ID инвентаря и индекс выбранного слота
|
||||
player.get_inventory(playerid: int) -> int, int
|
||||
|
||||
-- Устанавливает выбранный слот
|
||||
-- Устанавливает выбранный слот (индекс берётся по модулю размера хотбара)
|
||||
player.set_selected_slot(playerid: int, slotid: int)
|
||||
|
||||
-- Возвращает / устанавливает размер хотбара - число первых слотов инвентаря игрока,
|
||||
-- доступных для выбора. player.set_selected_slot берёт индекс по модулю этого числа,
|
||||
-- а при уменьшении размера выбранный слот сдвигается в допустимый диапазон.
|
||||
-- По умолчанию - `hotbar-size` из `config/defaults.toml` (10), в мире не сохраняется.
|
||||
-- На клиенте эти слоты показывает хотбар, они выбираются колесом мыши и цифровыми клавишами.
|
||||
player.get_hotbar_size(playerid: int) -> int
|
||||
player.set_hotbar_size(playerid: int, size: int)
|
||||
|
||||
-- Возвращает позицию выбранного блока
|
||||
player.get_selected_block(playerid: int) -> x,y,z
|
||||
|
||||
|
|
|
|||
|
|
@ -219,6 +219,8 @@
|
|||
> [!WARNING]
|
||||
> Слоты без привязки к инвентарю не будут отображаться. Под привязкой к инвентарю понимается связь UI элемента inventory с инвентарём по id. Которая может быть явно создана через `inventory_ui.inventory = inventory_id`. [(см ui.md)](scripting/ui.md#инвентарь-inventory)
|
||||
|
||||
Пак может заменить экран инвентаря игрока и хотбар своими макетами через ключи `inventory-layout` (по умолчанию `"core:inventory"`) и `hotbar-layout` в `config/defaults.toml`. Корневой элемент такого макета - `inventory`, он привязывается к инвентарю игрока. Макет хотбара ставится внизу по центру экрана, если у него нет `position-func`.
|
||||
|
||||
## Одиночный слот - *slot*
|
||||
|
||||
Элемент должен находиться внутри `inventory` элемента, без посредников.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue