Entity
The entity interface
e = Entity.spawn("Slime", 79, 29)
e:move(29, 29, 10, { damage = 10 })
e.dead = true
Player.heal()
See EntityRef for what you can do with entities.
Properties
player
Entity.player: EntityRefGet the player entity
Also available as Player globally.
Entity.player.x = 79
Player.x = 79 -- same effect
persistence
Entity.persistence: stringGet/Set the active persistence id
Functions
get
Entity.get(x: number,--
horizontal position
y: number--
vertical position
) → EntityRef--
found entity
Retrieve an entity on a position
Warning: Unsuitable for multiple entities on a position
get_all
Entity.get_all(x: number,--
horizontal position
y: number--
vertical position
) → ()Retrieve all entities on a position
persistence_skip
Entity.persistence_skip() → ()Skip the persistence slot
new
Entity.new(x: number,--
horizontal position
y: number--
vertical position
) → ()Create a new generic entity
spawn
Entity.spawn(factory: string,--
entity factory id
x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn entity
The below generic options are available for most other spawn functions too.
Generic Options
| Name | Type | Default | Description |
|---|---|---|---|
| flag | table | - | Entity flags table |
| instrument | string | - | Instrument identifier |
| fg | table | - | Foreground color |
| bg | table | - | Background color |
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| func | string | - | Spawn function character |
light_circle
Entity.light_circle(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn light circle
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| r | number | 255 | red |
| g | number | 255 | green |
| b | number | 255 | blue |
| offset | number | 0 | time offset for pulse (s) |
| collision | bool | false | shadows |
| radius | number | 8 | circle radius |
| amplitude | number | 0 | pulse amplitude |
| period | number | Beat | pulse period |
light_cone
Entity.light_cone(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn light cone
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| r | number | 255 | red |
| g | number | 255 | green |
| b | number | 255 | blue |
| offset | number | 0 | time offset for pulse (s) |
| collision | bool | false | shadows |
| radius | number | 8 | cone radius |
| angle | number | 0 | cone angle |
| amplitude | number | 0 | pulse amplitude |
| period | number | Beat | pulse period |
| rotation | number | 0 | rotation period |
explosion
Entity.explosion(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn explosion
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| instrument | string | Neutral | entity instrument |
| count | number | 1 | amount of rings |
| speed | number | 50 | speed of explosion |
| radius | number | 4 | size of explosion |
| radius_p | number | 1 | distance p-norm param |
| damage | number | 0 | amount of damage |
laser
Entity.laser(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn laser
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| instrument | string | Neutral | entity instrument |
| dx | number | 1 | horizontal direction |
| dy | number | 1 | vertical direction |
| offset | number | 0 | laser offset |
| scale | number | 1 | laser scale |
text
Entity.text(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn text
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| text | string | - | text to display |
| font | string | - | text font |
| center | bool | true | horizontal center |
| cost | bool | false | special coin cost mode |
| r | number | 255 | default text color red |
| g | number | 255 | default text color green |
| b | number | 255 | default text color blue |
image
Entity.image(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn image
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| path | string | - | image path |
| center | bool | true | horizontal center |
| collision | bool | false | image collision |
| r | number | 255 | default image color red |
| g | number | 255 | default image color green |
| b | number | 255 | default image color blue |
animation
Entity.animation(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRefSpawn animation
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| path | string | - | animation path |
| duration | number | Beat | animation frame duration (s) |
| oneshot | bool | false | play once and kill entity |
| sync | bool | false | synchronize animation to music |
| background | bool | true | show in background |
| r | number | 255 | default animation color red |
| g | number | 255 | default animation color green |
| b | number | 255 | default animation color blue |
window
Entity.window(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn window
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| direction | string | - | window direction (e.g. "up") |
| r | number | 255 | default animation color red |
| g | number | 255 | default animation color green |
| b | number | 255 | default animation color blue |
skin
Entity.skin(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn skin
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| skin | string | - | entity skin id |
| collision | bool | true | entity collision |
spawner
Entity.spawner(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn spawner
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| rate | number | Beat | spawn delay (s) |
| factory | string | - | entity factory id |
| instrument | string | Neutral | entity instrument |
| ch | string | - | spawner character |
| function_self | string | - | spawner function char |
| function_spawn | string | - | spawned entity function char |
item
Entity.item(x: number,--
horizontal position
y: number,--
vertical position
options: table | nil--
settings
) → EntityRef--
spawned entity
Spawn item
Specific Options
| Name | Type | Default | Description |
|---|---|---|---|
| type | string | - | item type identifier |
| level | number | 0 | item level |
| id | string | - | item custom identifier |