mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Fix docs and comments
This commit is contained in:
parent
8a197517ed
commit
2e2dd2e781
2 changed files with 8 additions and 6 deletions
|
@ -147,15 +147,17 @@ Queries are uncached by default, this is generally very cheap unless you have hi
|
|||
```luau
|
||||
function World:target(
|
||||
entity: Entity, -- The entity
|
||||
relation: Entity -- The relationship between the entity and the target
|
||||
): Entity? -- Returns the parent of the child
|
||||
relation: Entity, -- The relationship between the entity and the target
|
||||
nth: number, -- The index
|
||||
): Entity? -- The target for the relationship at the specified index.
|
||||
|
||||
```
|
||||
|
||||
Get the target of a relationship.
|
||||
|
||||
This will return a target (second element of a pair) of the entity for the specified relationship.
|
||||
This will return a target (second element of a pair) of the entity for the specified relationship. The index allows for iterating through the targets, if a single entity has multiple targets for the same relationship.
|
||||
|
||||
If there is no pair with specified relationship, it will return nil.
|
||||
If the index is larger than the total number of instances the entity has for the relationship or if there is no pair with the specified relationship on the entity, the operation will return nil.
|
||||
|
||||
## parent()
|
||||
```luau
|
||||
|
@ -169,5 +171,5 @@ Get parent (target of ChildOf relationship) for entity. If there is no ChildOf r
|
|||
This operation is the same as calling:
|
||||
|
||||
```luau
|
||||
world:target(entity, jecs.ChildOf)
|
||||
world:target(entity, jecs.ChildOf, 0)
|
||||
```
|
||||
|
|
|
@ -1576,7 +1576,7 @@ export type World = {
|
|||
--- These should be used for static components for fast access.
|
||||
component: <T>(self: World) -> Entity<T>,
|
||||
--- Gets the target of an relationship. For example, when a user calls
|
||||
--- `world:target(id, ChildOf(parent))`, you will obtain the parent entity.
|
||||
--- `world:target(id, ChildOf(parent), 0)`, you will obtain the parent entity.
|
||||
target: (self: World, id: Entity, relation: Entity, nth: number) -> Entity?,
|
||||
--- Deletes an entity and all it's related components and relationships.
|
||||
delete: (self: World, id: Entity) -> (),
|
||||
|
|
Loading…
Reference in a new issue