mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 10:59:45 +00:00
update doc/*/entity-properties.md, doc/*/scripting/builtins/libentities.md
This commit is contained in:
parent
283e3c041e
commit
aab363cfb7
4 changed files with 34 additions and 0 deletions
|
|
@ -1,5 +1,17 @@
|
||||||
# Entity properties
|
# Entity properties
|
||||||
|
|
||||||
|
## User properties
|
||||||
|
|
||||||
|
Access to custom entity properties is provided through the table `entities.properties[id]["property"]`, where `id` is the entity definition index.
|
||||||
|
|
||||||
|
Custom properties follow the same pack inheritance and override rules as block and item properties, and must be declared in `pack:config/user-props.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
"pack:property_name" = {}
|
||||||
|
```
|
||||||
|
|
||||||
|
This makes the property available in Lua scripts as `entities.properties[entities.def_index("pack:entity")]["property"]`.
|
||||||
|
|
||||||
## Logic
|
## Logic
|
||||||
|
|
||||||
### *components*
|
### *components*
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,11 @@ entities.defs_count() -> int
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Table of custom entity properties (see ../../entity-properties.md)
|
||||||
|
entities.properties: table<int, table<string, object>>
|
||||||
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> The following functions for retrieving multiple entities return tables with integer keys (uid).
|
> The following functions for retrieving multiple entities return tables with integer keys (uid).
|
||||||
> For iteration, use `pairs`, and for calculating the table size, use `table.count_pairs`.
|
> For iteration, use `pairs`, and for calculating the table size, use `table.count_pairs`.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
# Свойства сущностей
|
# Свойства сущностей
|
||||||
|
|
||||||
|
## Пользовательские свойства
|
||||||
|
|
||||||
|
Доступ к пользовательским свойствам сущностей осуществляется через таблицу `entities.properties[id]["свойство"]`, где `id` - индекс определения сущности.
|
||||||
|
|
||||||
|
Пользовательские свойства следуют тем же правилам наследования и переопределения пакетов, что и свойства блоков и предметов, и должны быть объявлены в `pack:config/user-props.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
"pack:property_name" = {}
|
||||||
|
```
|
||||||
|
|
||||||
|
Это делает свойство доступным в Lua-скриптах как `entities.properties[entities.def_index("pack:entity")]["свойство"]`.
|
||||||
|
|
||||||
## Логика
|
## Логика
|
||||||
|
|
||||||
### Список компонентов - *components*
|
### Список компонентов - *components*
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ entities.def_index(name: string) -> int
|
||||||
entities.defs_count() -> int
|
entities.defs_count() -> int
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Таблица пользовательских свойств сущностей (см. ../../entity-properties.md)
|
||||||
|
entities.properties: table<int, table<string, object>>
|
||||||
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Следующие функции для получения нескольких сущностей возвращают таблицы с целочисленными ключами (uid).
|
> Следующие функции для получения нескольких сущностей возвращают таблицы с целочисленными ключами (uid).
|
||||||
> Для итерации нужно использовать pairs, для подсчёта размера таблицы - table.count_pairs.
|
> Для итерации нужно использовать pairs, для подсчёта размера таблицы - table.count_pairs.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue