rewriting on_inventory_interact

This commit is contained in:
Xertis 2026-03-16 00:53:57 +03:00
parent f2684edf1f
commit 8ae35c0a5e
6 changed files with 62 additions and 21 deletions

View file

@ -221,6 +221,18 @@ function on_hud_close(playerid: int)
Called on world close (before saving)
```lua
function on_inventory_interact(invid: int, slot: int, mode: int, action: int)
```
Triggered when a player interacts with inventory slots.
| ACTION / MODE | (0) PRIMARY | (1) SECONDARY |
| ------------- | -------------------------------------------------- | ------------------------------------------------------ |
| (0) PUT | Places all items; if occupied, swaps them. | Places a single item from the cursor into the slot. |
| (1) TAKE | Picks up all items from the slot. | Picks up half of the items from the slot (rounded up). |
| (2) SHARE | Triggers the share event for the inventory layout. | Undefined |
## *events* library
```lua

View file

@ -231,11 +231,15 @@ function on_hud_close(playerid: int)
Вызывается при выходе из мира, перед его сохранением.
```lua
function on_hud_inventory_interact"(invid: int, slot: int, action: int)
function on_inventory_interact(invid: int, slot: int, mode: int, action: int)
```
Вызывается при взаимодействии со слотом игрока.
**action** отвечает за тип взаимодействия (0 - левый клик, 1 - правый клик, 2 - левый клик + шифт)
Вызывается при взаимодействии со слотами игроком
| ACTION / MODE | (0) PRIMARY | (1) SECONDARY |
| --------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------- |
| `(0) PUT` | Кладёт все предметы в слот, если другой предмет в слоте - обмен | Кладёт в слот один предмет из слота курсора |
| `(1) TAKE` | Забирает все предметы из слота | Берёт половину предметов из слота (округление вверх) |
| `(2) SHARE` | Вызывает share ивент у макета инвентаря | Не определён |
## События ECS
События **ECS** описаны [тут](ecs.md#события-компонента)