Entity
Most of these functions will throw if the entity has been erased. entity:will_erase_eof() and entity:deleted() will never throw and can be used to see if the entity is still safe to use.
entity:id()
Returns the id for the entity.
entity:name()
Returns the displayed name for the entity.
entity:set_name(name)
Sets the displayed name for the entity.
Automatically set for Players.
entity:element()
Returns the Element for the entity.
entity:set_element(element)
element: Element
Sets the Element for the entity, affects super effectiveness of incoming attacks.
Automatically set for Players.
entity:facing()
Returns the facing Direction of the entity.
Many mods use this to decide which direction to move in.
entity:facing_away()
Returns Direction
Same as Direction.reverse(entity:facing())
entity:set_facing(direction)
Returns the facing Direction of the entity.
Used by the engine to resolve how to display the visual based on perspective.
This should be set to either Direction.Left or Direction.Right generally.
Many mods use this to decide which direction to move in.
entity:team()
Returns the Team of the entity
entity:set_team(team)
teamTeam.OtherTeam.RedTeam.Blue
Modifies which team the entity is on. If the entity is a Player the perspective may flip.
entity:is_team(team)
Returns a boolean.
Same as entity:team() == team
entity:owner()
Returns an Entity, Team, or nil
entity:set_owner(team_or_entity?)
Marks a team or entity as the owner of this entity. If team_or_entity is unset the entity will be reverted to having no owner.
If a team or entity has too many entities claimed, the oldest claimed entity will be deleted.
By default, entities can own one other entity, teams can own two entities.
entity:get_tile(direction?, distance?)
direction: Directiondistance: integer
Returns a tile distance many tiles in direction's direction, or nil.
Returns the current tile if any parameters are unset.
entity:current_tile()
Returns the tile at the same position as the entity.
entity:field()
Deprecated. Use Field directly.
entity:spawned()
Returns true if the entity has spawned.
Usually set to true the frame after Field.spawn() is called with this entity.
entity:hittable()
Returns true if the entity:
- Is Living
- Hitbox is enabled
- Has health > 0
- On the field
- Not deleted
Different from living:hitbox_enabled()
entity:sharing_tile()
Returns true if other entities can stand on this tile.
entity:enable_sharing_tile(share?)
Allows other entities to stand on tiles reserved by this entity.
entity:ignoring_negative_tile_effects()
Returns true if negative tile effects should be ignored for this entity.
Affects only movement and idle effects, such as Cracked tiles converting to Broken or damage from Poison tiles. Does not affect tile interactions with attacks, such as freezing on Ice tiles when hit with an Aqua attack.
entity:ignore_negative_tile_effects(enabled?)
The entity will ignore negative tile effects when active.
Automatically set for Spells and Artifacts.
entity:ignoring_hole_tiles()
Returns true if the entity should be able to walk on Broken and PermaHole tiles.
entity:ignore_hole_tiles(enabled?)
Allows the entity to walk on Broken and PermaHole tiles.
Automatically set for Spells and Artifacts.
entity:movement_offset()
Returns { x: number, y: number }.
This table represents the temporary offset applied to the entity by movement.
entity:set_movement_offset(x, y)
Overwrites the frame temporary movement offset.
entity:offset()
Returns { x: number, y: number }
Same as entity:sprite():offset()
entity:set_offset(x, y)
Same as entity:sprite():set_offset(x, y)
entity:elevation()
Returns the elevation of the entity.
entity:set_elevation(elevation)
Vertical offset for the entity. When the elevation changes the sprite moves, but health will stay in the same position.
Positive elevation moves the entity upwards.
entity:height()
Returns the height of the entity, used to determine the range where hit artifacts should appear.
entity:set_height(height)
Sets the height of the entity.
entity:sprite()
Returns a Sprite, can be used to modify the entity's appearance.
entity:texture()
Returns a string.
Same as entity:sprite():texture()
entity:set_texture(path)
Same as entity:sprite():set_texture(path)