Host typegenerated
World
Finding, creating and removing the objects in a game. Every object in a scene (a player, an enemy, a button) is an entity.
17 members · engine 0.1.0
World.despawn(entity: Entity) -> unitRemoves an object, and everything attached to it, from the game. Used when an enemy dies or a bullet hits something.World.exists(entity: Entity) -> boolWhether an object still exists. Check before using an object you stored earlier, since it may have been removed since.World.find(name: String) -> EntityFinds an object by the name it was given in the scene, such asWorld.find("Player"). Givesnullif there is none.World.has_tag(entity: Entity, tag: String) -> boolWhether an object has a tag, a label such as"enemy"given to it in the scene.World.is_active(entity: Entity) -> boolWhether an object is switched on. An object switched off, or inside one that is, is hidden and does nothing.World.nearest(tag: String, position: Vec3) -> EntityThe closest active object with an authored tag to a world-space Vec3 position, including parent transforms. Gives null if none has a usable transform. Equal distances keep world order.World.property_number(entity: Entity, name: String, fallback: number) -> numberReads a number set up for another object's script, such as a bullet's damage, or givesfallbackif there is none.World.send_signal(entity: Entity, name: String, value: number) -> unitSends a number to another object under a name, for its script to collect withtake_signal. Older style: events and calling another script's functions are clearer.World.set_active(entity: Entity, on: bool) -> unitSwitches an object, and everything inside it, on or off. This is how menus and screens are shown and hidden.World.set_parent(entity: Entity, parent: Entity) -> unitAttaches an object to another, so it moves, turns and scales with it.nulldetaches it.World.set_property(entity: Entity, name: String, value: unknown) -> unitSets a starting value on a newly created object's script, before it starts. For example, a bullet's speed right after spawning it.World.set_shape_point(index: number, x: number, y: number) -> unitMoves one corner, numbered 0 to 7, of this object's custom polygon shape.World.spawn(prefab: Prefab) -> EntityCreates a new object from a prefab, a reusable template such as a bullet or an enemy, and gives it back so you can position it.World.spawn_child(prefab: Prefab, parent: Entity) -> EntityCreates a new object from a prefab, already attached to a parent object.World.take_signal(name: String) -> numberCollects the numbers other scripts sent to this object under a name withsend_signal, added together. Gives 0 when nothing arrived.World.with_tag(tag: String) -> List<Entity>Every switched-on object with a tag, as a list:for enemy in World.with_tag("enemy") { ... }. Looks through the whole game, so call it once per frame, not in a loop.World.within_radius(tag: String, position: Vec3, radius: number) -> List<Entity>A snapshot list of active tagged objects within an inclusive world-space radius of a Vec3 position, nearest first; ties keep world order. Skips unusable transforms. Empty when none match; over 8192 results is an error. Negative or NaN radii are errors; positive infinity searches the whole world.
- Source
- docs/generated/decay-api.json
- Schema
- v1
- Engine version
- 0.1.0
- Source commit
909aca81368b