fix: use composition.reg_id for entity identity in slot_of
get_children() returns fresh userdata wrappers without __eq; raw == compares Lua pointers (fails across separate get_children calls). slot_of now reads composition.reg_id from each child to find the matching slot, making contains/remove reliable across wrapper instances.
This commit is contained in:
10
README.md
10
README.md
@@ -97,6 +97,11 @@ Non-item children (future use) are silently excluded.
|
||||
|
||||
**Syntax:** `inventory.contains(container: entity, item: entity) -> bool`
|
||||
|
||||
**Example:**
|
||||
```lua
|
||||
local has_rock = inventory.contains(backpack, rock)
|
||||
```
|
||||
|
||||
**Description:** Returns `true` if `item` is currently a child of
|
||||
`container` under a synthetic slot.
|
||||
|
||||
@@ -104,6 +109,11 @@ Non-item children (future use) are silently excluded.
|
||||
|
||||
**Syntax:** `inventory.count(container: entity) -> number`
|
||||
|
||||
**Example:**
|
||||
```lua
|
||||
local n = inventory.count(backpack)
|
||||
```
|
||||
|
||||
**Description:** Returns the number of items currently in `container`.
|
||||
Equivalent to `#inventory.contents(container)`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user