update doc/*/scripting/ecs.md

This commit is contained in:
MihailRis 2026-07-21 23:13:09 +03:00
parent 3c7b7a9318
commit c023697bcc
2 changed files with 22 additions and 0 deletions

View file

@ -38,6 +38,17 @@ entity:set_enabled(name: str, enable: bool)
entity:get_player() -> int or nil
```
## Custom Components
A component is defined as a script in `{pack}/scripts/components/{name}.lua`.
The component will be available for use in the entity definition as `{pack}:{name}`.
Example: `core:scripts/components/pathfinding.lua` -> `core:pathfinding`.
For **each** entity containing a component, a **separate instance** is created with **its own namespace** within the pack namespace.
Global variables declared in it act as public fields of the component (same for global functions).
Entity components are specified via the ["components" list](../entity-properties.md#components)
## Built-in components
### Transform

View file

@ -180,6 +180,17 @@ rig:get_color() -> vec3
rig:set_color(color: vec3)
```
## Пользовательские компоненты
Компонент описывается в виде скрипта `{пак}/scripts/components/{имя}.lua`.
Компонент будет доступен для использования в описании сущности как `{пак}:{имя}`.
Пример: `core:scripts/components/pathfinding.lua` -> `core:pathfinding`.
Для **каждой** сущности, содержащей компонент, создаётся **отдельный экземпляр** со **своим пространством имен** внутри пространства имён пака.
Глобальные переменные, объявляемые в нём, играют роль публичных полей компонента (как и глобальные функции).
Компоненты сущности указываются через [список "components"](../entity-properties.md#cписок-компонентов---components)
> [!WARNING]
> При выходе сущности за пределы зоны прогрузки она удаляется, вызывая события.
> При повторном попадании в зону прогрузки сущность спавнится заново.