EntityRef
Wraps an entity instance
Properties
id
EntityRef.id: stringGet the entity id type
Only some entity types have a special identifier. It is mostly for internal usage.
val
EntityRef.val: stringGet/Set the value store identifier
behavior_tree
EntityRef.behavior_tree: stringGet/Set the behavior tree by identifier
behavior_tree_delta
EntityRef.behavior_tree_delta: numberGet/Set the delta time between behavior tree steps
instrument
EntityRef.instrument: stringGet/Set the entity instrument.
Instruments
| Value | Color | Description |
|---|---|---|
| Kick | Red | The explosion instrument |
| Snare | Yellow | The shooting instrument |
| Extra1 | - | Usage specific |
| Extra2 | - | Usage specific |
persistence_key
EntityRef.persistence_key: stringGet the persistence key of the entity
persistence_store
EntityRef.persistence_store: stringGet/Set the persistence store of the entity This can be used to store information of an entity permanently
positional_hash
EntityRef.positional_hash: numberGet the positional hash of the entity
hovered
EntityRef.hovered: boolGet the hovered state of the entity An entity can be hovered with the mouse cursor
skin
EntityRef.skin: stringGet/Set the skin of the entity by identifier
animation
EntityRef.animation: stringGet/Set the animation of the entity by path
image
EntityRef.image: stringGet/Set the image of the entity by path This loads an animation with a single frame.
char
EntityRef.char: stringGet/Set the alternate display single character A relict of the time when the game was a more classic roguelike
color_fg
EntityRef.color_fg: tableGet/Set the foreground color The table must contain r, g, b numeric [0, 255] integers
color_bg
EntityRef.color_bg: tableGet/Set the background color The table must contain r, g, b numeric [0, 255] integers
draw_order
EntityRef.draw_order: stringGet/Set the draw order by quick setting identifier The getter may not work reliably with other settings
Draw Orders
| Name |
|---|
| normal |
| foreground |
| background |
| overlay |
dead
EntityRef.dead: boolGet/Set the death state
stuck
EntityRef.stuck: boolGet/Set the stuck state
health_abs
EntityRef.health_abs: numberGet/Set the absolute health number
health_rel
EntityRef.health_rel: numberGet/Set the relative health number
health_max
EntityRef.health_max: numberGet/Set the maximum health number
pos
EntityRef.pos: tableGet/Set the entity position as named table
Entity.player.pos = {x=79, y=29} -- works
x = Entity.player.pos.x -- works
Entity.player.pos.x = x -- no effect
Entity.player.x = x -- works
x
EntityRef.x: numberGet/Set the horizontal coordinate
y
EntityRef.y: numberGet/Set the vertical coordinate
speed
EntityRef.speed: tableGet/Set the entity speed as named table
Works the same as pos.
speed_x
EntityRef.speed_x: numberGet/Set the horizontal entity speed
speed_y
EntityRef.speed_y: numberGet/Set the vertical entity speed
velocity
EntityRef.velocity: tableGet/Set the entity velocity as named table
Works the same as pos.
velocity_x
EntityRef.velocity_x: numberGet/Set the horizontal entity velocity
velocity_y
EntityRef.velocity_y: numberGet/Set the vertical entity velocity
dir
EntityRef.dir: numberGet/Set the entity direction in range [0; 1]
collision
EntityRef.collision: boolGet/Set the collision flag
collision_disable
EntityRef.collision_disable: boolGet/Set the collision_disable flag
movement_collision
EntityRef.movement_collision: boolGet/Set the movement_collision flag
static_collision
EntityRef.static_collision: boolGet/Set the static_collision flag
player_collision
EntityRef.player_collision: boolGet/Set the player_collision flag
bullet_collision
EntityRef.bullet_collision: boolGet/Set the bullet_collision flag
bullet_cancel
EntityRef.bullet_cancel: boolGet/Set the bullet cancel flag
Entities with this flag remove all bullets on death
animation_oneshot
EntityRef.animation_oneshot: boolGet/Set the animation_oneshot flag
animation_sync
EntityRef.animation_sync: boolGet/Set the animation_sync flag
animation_loop
EntityRef.animation_loop: boolGet/Set the animation_loop flag
animation_mirror
EntityRef.animation_mirror: boolGet/Set the animation_mirror flag
animation_mirror_ver
EntityRef.animation_mirror_ver: boolGet/Set the animation_mirror_ver flag
animation_live
EntityRef.animation_live: boolGet/Set the animation_live flag
dissolve_kill
EntityRef.dissolve_kill: boolGet/Set the dissolve_kill flag
pushable
EntityRef.pushable: boolGet/Set the pushable flag
flying
EntityRef.flying: boolGet/Set the flying flag
gravity_force
EntityRef.gravity_force: boolGet/Set the gravity_force flag
invisible
EntityRef.invisible: boolGet/Set the invisible flag
invincible
EntityRef.invincible: boolGet/Set the invincible flag
background
EntityRef.background: boolGet/Set the background flag
foreground
EntityRef.foreground: boolGet/Set the foreground flag
overlay
EntityRef.overlay: boolGet/Set the overlay flag
top
EntityRef.top: boolGet/Set the top flag
effect_text
EntityRef.effect_text: boolGet/Set the effect_text flag
effect_immune
EntityRef.effect_immune: boolGet/Set the effect_immune flag
effect_visible
EntityRef.effect_visible: boolGet/Set the effect_visible flag
laser_sensitive
EntityRef.laser_sensitive: boolGet/Set the laser_sensitive flag
boss_bar
EntityRef.boss_bar: boolGet/Set the boss_bar flag
boss_damage
EntityRef.boss_damage: boolGet/Set the boss_damage flag
boss_damage_disable
EntityRef.boss_damage_disable: boolGet/Set the boss_damage_disable flag
target_disable
EntityRef.target_disable: boolGet/Set the target_disable flag
damage_text
EntityRef.damage_text: boolGet/Set the damage_text flag
health_bar
EntityRef.health_bar: boolGet/Set the health_bar flag
health_bar_force
EntityRef.health_bar_force: boolGet/Set the health_bar_force flag
continue_clear
EntityRef.continue_clear: boolGet/Set the continue_clear flag
transcending
EntityRef.transcending: boolGet/Set the transcending flag
enemy
EntityRef.enemy: boolGet/Set the enemy flag
buddy
EntityRef.buddy: boolGet/Set the buddy flag
aggro
EntityRef.aggro: boolGet/Set the aggro flag
boss
EntityRef.boss: boolGet/Set the boss flag
sight
EntityRef.sight: boolGet/Set the sight flag
order
EntityRef.order: boolGet/Set the order flag
aura_intensity
PlayerEntityRef.aura_intensity: numberGet/Set the player aura intensity
life_mode
PlayerEntityRef.life_mode: stringGet/Set the player life mode
Life Modes
| Name | Description |
|---|---|
| health | Normal mode with health |
| reset | Reset the room on hit |
kick_follow
PlayerEntityRef.kick_follow: boolGet/Set the kick follow flag for the player
energy
PlayerEntityRef.energy: numberenergy_use
PlayerEntityRef.energy_use: numberflashlight_force
PlayerEntityRef.flashlight_force: boolGet/Set the flashlight force flag
When set to true, the flashlight will be on permanently, even when the player is currently not allowed to move.
flashlight_intensity
PlayerEntityRef.flashlight_intensity: numberGet/Set the flashlight intensity
flashlight_color
PlayerEntityRef.flashlight_color: tableGet the current flashlight color
flashlight_color_normal
PlayerEntityRef.flashlight_color_normal: tableGet the normal flashlight color
flashlight_color_aim
PlayerEntityRef.flashlight_color_aim: tableGet the aim flashlight color
move_lock
PlayerEntityRef.move_lock: boolGet/Set the movement lock flag
Functions
val_get_num
EntityRef:val_get_num(path: string--
path to value (e.g. "movement/damage")
) → numberRetrieve a number from the value store
val_get_str
EntityRef:val_get_str(path: string--
path to value (e.g. "movement/damage")
) → stringRetrieve a string from the value store
val_get_bool
EntityRef:val_get_bool(path: string--
path to value (e.g. "movement/damage")
) → boolRetrieve a bool from the value store
val_set_num
EntityRef:val_set_num(path: string,--
path to value (e.g. "movement/damage")
value: number--
numeric value
) → ()Override a number in the value store
val_set_str
EntityRef:val_set_str(path: string,--
path to value (e.g. "movement/damage")
value: string--
string value
) → ()Override a string in the value store
val_set_bool
EntityRef:val_set_bool(path: string,--
path to value (e.g. "movement/damage")
value: bool--
boolean value
) → ()Override a bool in the value store
instrument_compatible
EntityRef:instrument_compatible(instrument: string--
the instrument to check for (e.g. "Kick")
) → ()Check if the given instrument is compatible with the entity instrument The neutral instrument is compatible with all other instruments.
instrument_match
EntityRef:instrument_match(instrument: string--
the instrument to check for (e.g. "Kick")
) → ()Check if the given instrument matches with the entity instrument The neutral instrument matches no instruments. Only non-neutral instruments match when equal.
item_drop
EntityRef:item_drop(item: string,--
item identifier string (e.g. "Shuriken")
options: table | nil--
settings
) → ()Drops an item next to the entity
sound
EntityRef:sound(options: table--
settings
) → ()Play a sound effect at the entity position
Options
| Name | Type | Default | Description |
|---|---|---|---|
| path | string | - | sound file path |
| vol | number | 1 | sound volume |
| pan | number | 0 | pan value in range [-1, 1] |
| loops | number | - | amount of additional loops |
effect_push
EntityRef:effect_push(effect: string,--
effect identifier string (e.g. "Fire")
strength: number | nil--
effect strength (default 1.0)
) → ()Adds an effect to the entity
effect_check
EntityRef:effect_check(effect: string--
effect identifier string (e.g. "Fire")
) → bool--
true if affected
Checks if the entity is currently affected
effect_consume
EntityRef:effect_consume(effect: string--
effect identifier string (e.g. "Fire")
) → bool--
true if removed
Removes an effect from the entity
effect_resistant_get
EntityRef:effect_resistant_get(effect: string--
effect identifier string (e.g. "Fire")
) → bool--
true if resistant
Check if entity is resistant against the given effect
effect_resistant_set
EntityRef:effect_resistant_set(effect: string--
effect identifier string (e.g. "Fire")
) → ()Add resistance for given effect to entity
effect_weak_get
EntityRef:effect_weak_get(effect: string--
effect identifier string (e.g. "Fire")
) → bool--
true if weak
Check if entity is weak against the given effect
effect_weak_set
EntityRef:effect_weak_set(effect: string--
effect identifier string (e.g. "Fire")
) → ()Add weakness for given effect to entity
animation_wait
EntityRef:animation_wait() → ()Waits until the entity animation is complete
dissolve
EntityRef:dissolve() → ()Dissolves an entity resulting in a particle effect
kill
EntityRef:kill() → ()Kill the entity
purge
EntityRef:purge() → ()Purges an entity by removing without dissolving nor death
damage_abs
EntityRef:damage_abs(value: number--
absolute damage value
) → ()Applies damage by absolute value to the entity
damage_rel
EntityRef:damage_rel(value: number--
relative damage value
) → ()Applies damage by relative value to the entity
heal
EntityRef:heal() → ()Heals the entity to maximum health
heal_abs
EntityRef:heal_abs(value: number--
absolute health value
) → ()Apply heal by absolute value to the entity
heal_rel
EntityRef:heal_rel(value: number--
relative health value
) → ()Apply heal by relative value to the entity
set
EntityRef:set(x: number,--
horizontal coordinate
y: number--
vertical coordinate
) → ()Sets the entity position to the specified coordinates
at
EntityRef:at(x: number,--
horizontal coordinate
y: number--
vertical coordinate
) → bool--
true if coordinates match
Check if the entity center is at the specified coordinates
inside
EntityRef:inside(area: table--
area data
) → bool--
true if center inside area
Check if the entity center is inside the given area
center
EntityRef:center() → ()Moves the entity into the center of the room
speed_set
EntityRef:speed_set(x: number,--
horizontal component
y: number--
vertical component
) → ()Sets the speed to the specified components
velocity_set
EntityRef:velocity_set(x: number,--
horizontal component
y: number--
vertical component
) → ()Sets the velocity to the specified components
dir_reset
EntityRef:dir_reset() → ()Reset the entity direction
find_buddy
Find a buddy entity in range
Buddies are entities with the buddy flag set. However, for enemies, only other enemies are buddies. The player is a buddy as well.
Options
| Name | Type | Default | Description |
|---|---|---|---|
| dx | number | 0 | Preferred horizontal direction |
| dy | number | 0 | Preferred vertical direction |
find_target
Find a target entity in range
Targets are entities with the enemy flag set. However, for enemies, only buddies are targets. The player is a buddy as well.
Options
| Name | Type | Default | Description |
|---|---|---|---|
| dx | number | 0 | Preferred horizontal direction |
| dy | number | 0 | Preferred vertical direction |
push
EntityRef:push(dx: number,--
horizontal push amount
dy: number--
vertical push amount
) → ()Pushes the entity into a given direction
move
EntityRef:move(x: number,--
horizontal coordinate
y: number,--
vertical coordinate
speed: number,--
step delay (s) is 1.0 / speed
options: table--
settings
) → ()Moves the entity to a specified position
Options
| Name | Type | Default | Description |
|---|---|---|---|
| damage | number | 0 | collision damage |
| range_min | number | 0 | minimum range for movement |
| range_max | number | 0 | maximum range for movement |
| range_aggro | number | 0 | range for aggressive flag |
| path | bool | true | path-finding enabled |
| path_step | bool | false | path-finding special mode |
| target_once | bool | false | target-once special mode |
move_wait
EntityRef:move_wait() → ()Waits for the entity movement to complete
stop
EntityRef:stop() → ()Stops the entity movement
follow
EntityRef:follow(speed: number,--
step delay (s) is 1.0 / speed
options: table--
settings
) → ()Follows an entity
Options
| Name | Type | Default | Description |
|---|---|---|---|
| damage | number | 0 | collision damage |
| range_min | number | 0 | minimum range for movement |
| range_max | number | 0 | maximum range for movement |
| range_aggro | number | 0 | range for aggressive flag |
| path | bool | true | path-finding enabled |
| path_step | bool | false | path-finding special mode |
| target_once | bool | false | target-once special mode |
distance_pos
EntityRef:distance_pos(x: number,--
horizontal coordinate
y: number--
vertical coordinate
) → number--
distance to position
Calculate distance to a specified position
distance_rect
EntityRef:distance_rect(x1: number,--
minimum horizontal coordinate
y1: number,--
minimum vertical coordinate
x2: number,--
maximum horizontal coordinate
y2: number--
maximum vertical coordinate
) → number--
distance to rectangle
Calculate distance to a specified rectangle
distance_entity
Calculate distance to a specified entity
hitbox_pos
EntityRef:hitbox_pos(x: number,--
horizontal coordinate
y: number--
vertical coordinate
) → number--
distance from hitbox to position
Calculate distance from hitbox to position
hitbox_rect
EntityRef:hitbox_rect(x1: number,--
minimum horizontal coordinate
y1: number,--
minimum vertical coordinate
x2: number,--
maximum horizontal coordinate
y2: number--
maximum vertical coordinate
) → number--
distance from hitbox to rectangle
Calculate distance from hitbox to rectangle
histbox_entity
EntityRef:histbox_entity() → number--
distance from hitbox to entity
Calculate distance from hitbox to entity
flag_get
EntityRef:flag_get(flag: string--
flag name (e.g. "invisible")
) → bool--
state of flag
Gets a flag by identifier name
flag_set
EntityRef:flag_set(flag: string,--
flag name (e.g. "invisible")
value: bool--
new flag value
) → ()Sets a flag by identifier name
energy_consume
PlayerEntityRef:energy_consume(options: table--
settings
) → ()Consumes energy with optional draining features
Options
| Name | Type | Default | Description |
|---|---|---|---|
| drain | bool | true | Use remaining energy on fail |
| drain_use | bool | false | Use drained energy |
| drain_gen | bool | false | Generates drain on consumption |
skin_push
PlayerEntityRef:skin_push(id: string--
skin identifier
) → ()Pushes a skin onto the stack This does nothing if the skin is already on the stack.
skin_pop
PlayerEntityRef:skin_pop(id: string--
skin identifier
) → bool--
true if skin was on stack
Removes a skin from the stack
skin_check
PlayerEntityRef:skin_check(id: string--
skin identifier
) → bool--
true if skin is on stack
Checks if a skin is on the stack
skin_reset
PlayerEntityRef:skin_reset() → ()Clears the skin stack