feat(composition): expose get_container for inventory readback

Add composition.get_container(entity) -> table or nil. Returns the
container block from the entity's template (e.g. {kind="list"}), or
nil if the template declared no container block. Loud-Error if the
entity was not created by composition.

The internal storage (tpl.container) was already present since v0.2.0
(stashed on the template record with a comment "B.2 reads this") but
had no public getter. This fills the oversight without any semantic
change to v0.2.0.
This commit is contained in:
Axel Meyer
2026-06-13 17:30:49 +02:00
parent 87357571bd
commit ccc4bb5643
2 changed files with 27 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ Template-Only-Subset + set_tag + container declaration.
- `list_by_template(id)`, `list_by_tag(tag)`
- `destroy(entity)`
- `set_tag(entity, tag, present)` — v0.2: runtime tag add/remove
- `get_container(entity)` — v0.2: read back the container block from entity's template
**Deferred (Loud-Error if attempted):**
- `slots` block → Phase D trigger (Composite Items with Sub-Items)
@@ -180,6 +181,15 @@ when items move between world and inventory.
destroys via `engine.entity.destroy`. Idempotent. If entity wasn't
composition-created, falls through to `entity.destroy`.
### `composition.get_container(entity)`
**Syntax:** `composition.get_container(entity) -> table or nil`
**Description:** Returns the `container` block from the entity's template
(e.g. `{kind="list"}`), or `nil` if the template declared no `container`
block. Loud-Error if `entity` was not created by composition. Used by
`lib-core.inventory-list` to validate container entities at runtime.
### `composition.list_templates()`
**Syntax:** `composition.list_templates() -> {id, ...}`