Update world.md

This commit is contained in:
silly-spongus 2024-09-29 04:04:46 -03:00 committed by GitHub
parent db710cf5be
commit 2337434fac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,10 +81,7 @@ local Health = world:component() :: jecs.Entity<number>
local Entity = world:entity() local Entity = world:entity()
world:set(Entity, Health, 100) world:set(Entity, Health, 100)
local EntityWithNoHealth = world:entity()
print(world:get(Entity, Health)) -- Outputs 100 print(world:get(Entity, Health)) -- Outputs 100
print(world:get(EntityWithNoHealth, Health)) -- Outputs nil
``` ```
```ts [typescript] ```ts [typescript]
@ -93,10 +90,7 @@ const Health = world.component<number>();
const Entity = world.entity(); const Entity = world.entity();
world.set(Entity, Health, 100); world.set(Entity, Health, 100);
const EntityWithNoHealth = world.entity();
print(world.get(Entity, Health)) // Outputs 100 print(world.get(Entity, Health)) // Outputs 100
print(world.get(EntityWithNoHealth, Health)) // Outputs undefined (nil)
``` ```
::: :::
@ -114,7 +108,7 @@ Example:
::: code-group ::: code-group
```luau [luau] ```luau [luau]
local IsMoving = world:component() local IsMoving = world:component()
local Ragdolled = world:component() -- This is a tag, meaning it won't contain data local Ragdolled = world:entity() -- This is a tag, meaning it won't contain data
local Health = world:component() :: jecs.Entity<number> local Health = world:component() :: jecs.Entity<number>
local Entity = world:entity() local Entity = world:entity()
@ -130,7 +124,7 @@ print(world:has(Entity, Ragdolled)) -- Outputs true
```ts [typescript] ```ts [typescript]
const IsMoving = world.component(); const IsMoving = world.component();
const Ragdolled = world.component(); -- This is a tag, meaning it won't contain data const Ragdolled = world.entity(); -- This is a tag, meaning it won't contain data
const Health = world.component<number>(); const Health = world.component<number>();
const Entity = world.entity(); const Entity = world.entity();