Binding of Isaac - Afterbirth+ Lua Reference/Guide
Entity Class Reference
Inheritance diagram for Entity:
EntityBomb EntityEffect EntityFamiliar EntityKnife EntityLaser EntityNPC EntityPickup EntityPlayer EntityProjectile EntityTear

Public Member Functions

table GetData ()
 
 Update ()
 
 Render (Vector Offset)
 
boolean RenderShadowLayer (Vector Offset)
 
 PostRender ()
 
boolean TakeDamage (float Damage, integer Flags, EntityRef Source, integer DamageCountdown)
 
boolean HasMortalDamage ()
 
 Kill ()
 Kills the entity and makes a blood splat or gibs. More...
 
 Die ()
 
 Remove ()
 
 BloodExplode ()
 Explodes with gibs and blood. More...
 
 AddVelocity (Vector Velocity)
 
 MultiplyFriction (float Value)
 
 SetColor (Color Color, integer Duration, integer Priority, boolean Fadeout, boolean Share)
 
const ColorGetColor ()
 
 SetSpriteFrame (string AnimationName, integer FrameNum)
 
 SetSpriteOverlayFrame (string AnimationName, integer FrameNum)
 
 SetSize (float Size, Vector SizeMulti, integer NumGridCollisionPoints)
 
boolean CollidesWithGrid ()
 
boolean IsEnemy ()
 return true for NPCs that are not controlled by the player More...
 
boolean IsActiveEnemy (boolean includeDead)
 return true for non background NPCs (ex: every enemy except fire and shopkeepers) More...
 
boolean IsVulnerableEnemy ()
 return true for enemies that can be damaged More...
 
boolean IsFlying ()
 
 AddEntityFlags (integer Flags)
 
 ClearEntityFlags (integer Flags)
 
integer GetEntityFlags ()
 
boolean HasEntityFlags (integer Flags)
 
boolean HasFullHealth ()
 
 AddHealth (float HitPoints)
 
 AddPoison (EntityRef Source, integer Duration, float Damage)
 
 AddFreeze (EntityRef Source, integer Duration)
 
 AddSlowing (EntityRef Source, integer Duration, float SlowValue, Color SlowColor)
 Makes the friction higher. More...
 
 AddCharmed (integer Duration)
 
 AddConfusion (EntityRef Source, integer Duration, boolean IgnoreBosses)
 
 AddMidasFreeze (EntityRef Source, integer Duration)
 
 AddFear (EntityRef Source, integer Duration)
 
 AddBurn (EntityRef Source, integer Duration, float Damage)
 
 AddShrink (EntityRef Source, integer Duration)
 
 RemoveStatusEffects ()
 
boolean Exists ()
 
boolean IsDead ()
 
boolean IsVisible ()
 
boolean IsInvincible ()
 
boolean CanShutDoors ()
 enemies keep the doors shut More...
 
boolean IsBoss ()
 bosses display health bar More...
 
BossId GetBossID ()
 
EntityGetLastParent ()
 
EntityGetLastChild ()
 
boolean HasCommonParentWithEntity (Entity Other)
 
boolean IsFrame (integer Frame, integer Offset)
 true every X frames More...
 
RNGGetDropRNG ()
 
SpriteGetSprite ()
 
EntityPlayer ToPlayer ()
 
EntityEffect ToEffect ()
 
EntityNPC ToNPC ()
 
EntityPickup ToPickup ()
 
EntityFamiliar ToFamiliar ()
 
EntityBomb ToBomb ()
 
EntityKnife ToKnife ()
 
EntityLaser ToLaser ()
 
EntityTear ToTear ()
 
EntityProjectile ToProjectile ()
 

Public Attributes

float Friction
 loaded from entity config More...
 
Vector Position
 
Vector Velocity
 
const EntityType Type
 
integer Variant
 
integer SubType
 
EntityType SpawnerType
 
integer SpawnerVariant
 
const ColorSplatColor
 
boolean Visible
 
const VectorPositionOffset
 
integer RenderZOffset
 
boolean FlipX
 
const VectorSpriteOffset
 
const VectorSpriteScale
 
float SpriteRotation
 
Vector SizeMulti
 
float Mass
 
float MaxHitPoints
 
float HitPoints
 
const integer Index
 
const VectorTargetPosition
 
GridCollisionClass GridCollisionClass
 
EntityCollisionClass EntityCollisionClass
 
float CollisionDamage
 
const integer SpawnGridIndex
 
EntityParent
 
EntityChild
 
EntityTarget
 
EntitySpawnerEntity
 
const integer FrameCount
 
const integer InitSeed
 
const integer DropSeed
 
float DepthOffset
 
float Size
 

Member Function Documentation

◆ AddBurn()

Entity::AddBurn ( EntityRef  Source,
integer  Duration,
float  Damage 
)

Adds a burn-effect to an enemy. Duration is in Number of Frames. Damage is the Damage taken per frame.

This code damages every entity in the room for 1 second with the damagesource set to the player. The total damage dealt is 30.
local player =Isaac.GetPlayer(0)
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddBurn(player,30,1)
end

◆ AddCharmed()

Entity::AddCharmed ( integer  Duration)

Adds a charmed-effect to an enemy. Duration is in Number of Frames. Charmed enemies are friendly towards isaac and attack other enemies.
AddCharmed(-1) makes the effect permanent and the enemy will follow you even to different rooms.

This code charms every entity in the room for 1 second.
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddCharmed(30)
end

◆ AddConfusion()

Entity::AddConfusion ( EntityRef  Source,
integer  Duration,
boolean  IgnoreBosses 
)

Adds a confusion effect to an entity.

This code confuses every entity in the room for 1 second while ignoring bosses.
local player =Isaac.GetPlayer(0) 
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddConfusion(player,30,true)
end

◆ AddEntityFlags()

Entity::AddEntityFlags ( integer  Flags)

Add EntityFlags to the entity. Flags are used to add specific effects like poisoning or freeze. You can add multiple flags at the same time by bitwise-concatenating them.

This code adds slowing and confusion to the enetity.
local player =Isaac.GetPlayer(0) 
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddEntityFlags(EntityFlag.FLAG_SLOW | EntityFlag.FLAG_CONFUSION)
end

◆ AddFear()

Entity::AddFear ( EntityRef  Source,
integer  Duration 
)

Adds a fear-effect to an entity.

This code frightens every entity in the room for 1 second.
local player =Isaac.GetPlayer(0) 
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddFear(player, 30)
end

◆ AddFreeze()

Entity::AddFreeze ( EntityRef  Source,
integer  Duration 
)

Freezes an entity, making it unable to move and attack.

This code freezes every entity in the room for half a second.
local player =Isaac.GetPlayer(0) 
for i, entity in ipairs(Isaac.GetRoomEntities()) do
	entity:AddFreeze(player, 30)
end

◆ AddHealth()

Entity::AddHealth ( float  HitPoints)

Heals an entity.

◆ AddMidasFreeze()

Entity::AddMidasFreeze ( EntityRef  Source,
integer  Duration 
)

Turns the entity into a gold statue (can't move, can't attack, drops coins when killed)

◆ AddPoison()

Entity::AddPoison ( EntityRef  Source,
integer  Duration,
float  Damage 
)

Adds a poison effect to the entity.

◆ AddShrink()

Entity::AddShrink ( EntityRef  Source,
integer  Duration 
)

Adds a shrink effect to the entity.

◆ AddSlowing()

Entity::AddSlowing ( EntityRef  Source,
integer  Duration,
float  SlowValue,
Color  SlowColor 
)

Makes the friction higher.

◆ AddVelocity()

Entity::AddVelocity ( Vector  Velocity)

Adds velocity to the entity. This can be used to move him in a certain direktion (for example as a result of collision)

◆ BloodExplode()

Entity::BloodExplode ( )

Explodes with gibs and blood.

◆ CanShutDoors()

boolean Entity::CanShutDoors ( )

enemies keep the doors shut.

◆ ClearEntityFlags()

Entity::ClearEntityFlags ( integer  Flags)

Removes all EntityFlags from the entity.

◆ CollidesWithGrid()

boolean Entity::CollidesWithGrid ( )

Returns true, if the entity is able to collide with the grid.

◆ Die()

Entity::Die ( )

Kills the entity and trigger its death animation.

◆ Exists()

boolean Entity::Exists ( )

Returns true, if this entity still exists.

◆ GetBossID()

BossId Entity::GetBossID ( )

If the entity is a boss, it returns its specific boss id. If it isnt a boss it will return 0.

◆ GetColor()

const Color& Entity::GetColor ( )

Returns the Color object assosiated to this entity.

◆ GetData()

table Entity::GetData ( )

Returns a table that contains all data assosiated with the entity. This can be used to add custom data as well.

Data associated with an entity does only persists in between rooms, when the entity is a player, familiar or the entity has the "EntityFlag.FLAG_PERSISTENT" Flag active. Data does not persists in between exiting the game to a menu, or when restarting/finishing a run.
This code adds custom data to an entity or prints it in the console if it exists.
if type(entity:GetData()["MyValue"]) == type(nil) then -- checks, if the Data does exist already
    entity:GetData()["MyValue"] = "Cool" -- assign a value to the data
else 
    print(entity:GetData()["MyValue"])  -- this will print "Cool" in the console
end

◆ GetDropRNG()

RNG& Entity::GetDropRNG ( )

Returns the assigned RNG object for the entity. This RNG is used to determine the items that are dropped on the entities death.

◆ GetEntityFlags()

integer Entity::GetEntityFlags ( )

Get the EntityFlags of the entity. This will be a number which acts like a bitmask.

This code prints something in the console, if the entity has a specific EntityFlag.
if entity:GetEntityFlags() & EntityFlag.FLAG_CONFUSION == EntityFlag.FLAG_CONFUSION then
    print("This entity is confused!")
end

◆ GetLastChild()

Entity& Entity::GetLastChild ( )

Returns the last entity spawned by this entity.

◆ GetLastParent()

Entity& Entity::GetLastParent ( )

Returns the last parent of this entity.

◆ GetSprite()

Sprite& Entity::GetSprite ( )

Return the sprite object of the entity.

◆ HasCommonParentWithEntity()

boolean Entity::HasCommonParentWithEntity ( Entity  Other)

◆ HasEntityFlags()

boolean Entity::HasEntityFlags ( integer  Flags)

Returns true, if the entity has all named EntityFlags set.

This code prints something in the console, if the entity has a specific EntityFlag.
if entity:HasEntityFlags(EntityFlag.FLAG_CONFUSION) then
    print("This entity is confused!")
end

◆ HasFullHealth()

boolean Entity::HasFullHealth ( )

◆ HasMortalDamage()

boolean Entity::HasMortalDamage ( )

The game adds taken damage to a damage buffer, which gets applied in the next frame. HasMortalDamage() returns true if the buffered damage is enough to kill the entity.

HasMortalDamage() will be updated additionally after TakeDamage() is called.

◆ IsActiveEnemy()

boolean Entity::IsActiveEnemy ( boolean  includeDead)

return true for non background NPCs (ex: every enemy except fire and shopkeepers)

◆ IsBoss()

boolean Entity::IsBoss ( )

bosses display health bar

◆ IsDead()

boolean Entity::IsDead ( )

◆ IsEnemy()

boolean Entity::IsEnemy ( )

return true for NPCs that are not controlled by the player

◆ IsFlying()

boolean Entity::IsFlying ( )

◆ IsFrame()

boolean Entity::IsFrame ( integer  Frame,
integer  Offset 
)

true every X frames

◆ IsInvincible()

boolean Entity::IsInvincible ( )

◆ IsVisible()

boolean Entity::IsVisible ( )

◆ IsVulnerableEnemy()

boolean Entity::IsVulnerableEnemy ( )

return true for enemies that can be damaged

◆ Kill()

Entity::Kill ( )

Kills the entity and makes a blood splat or gibs.

◆ MultiplyFriction()

Entity::MultiplyFriction ( float  Value)

◆ PostRender()

Entity::PostRender ( )

◆ Remove()

Entity::Remove ( )

Remove the entity from the game instantly, without doing any additional effects/animations.

◆ RemoveStatusEffects()

Entity::RemoveStatusEffects ( )

Removes all Status Effects from the entity.

◆ Render()

Entity::Render ( Vector  Offset)

Render the current sprite of the Entity at the current entity position + offset.

◆ RenderShadowLayer()

boolean Entity::RenderShadowLayer ( Vector  Offset)

Render the shadow / shadow layer again.

◆ SetColor()

Entity::SetColor ( Color  Color,
integer  Duration,
integer  Priority,
boolean  Fadeout,
boolean  Share 
)

Set the colormask for the entity. This can be used to tint the sprites in different colors.

This code changes the color of the sprite to a fully white sprite for 15 frames.
entity:SetColor(Color(1,1,1,1,255,255,255),15,1,false,false)

◆ SetSize()

Entity::SetSize ( float  Size,
Vector  SizeMulti,
integer  NumGridCollisionPoints 
)

Set the size ofthe entity.

◆ SetSpriteFrame()

Entity::SetSpriteFrame ( string  AnimationName,
integer  FrameNum 
)

◆ SetSpriteOverlayFrame()

Entity::SetSpriteOverlayFrame ( string  AnimationName,
integer  FrameNum 
)

◆ TakeDamage()

boolean Entity::TakeDamage ( float  Damage,
integer  Flags,
EntityRef  Source,
integer  DamageCountdown 
)
The game adds taken damage to a damage buffer, which gets applied in the next frame. Therefore, TakeDamage() will not decremented the entities HP immediately upon calling the function. Rather, it is only updated on the frame afterwards.

◆ ToBomb()

EntityBomb Entity::ToBomb ( )

◆ ToEffect()

EntityEffect Entity::ToEffect ( )

◆ ToFamiliar()

EntityFamiliar Entity::ToFamiliar ( )

◆ ToKnife()

EntityKnife Entity::ToKnife ( )

◆ ToLaser()

EntityLaser Entity::ToLaser ( )

◆ ToNPC()

EntityNPC Entity::ToNPC ( )

◆ ToPickup()

EntityPickup Entity::ToPickup ( )

◆ ToPlayer()

EntityPlayer Entity::ToPlayer ( )

◆ ToProjectile()

EntityProjectile Entity::ToProjectile ( )

◆ ToTear()

EntityTear Entity::ToTear ( )

◆ Update()

Entity::Update ( )

Member Data Documentation

◆ Child

Entity& Entity::Child

◆ CollisionDamage

float Entity::CollisionDamage

◆ DepthOffset

float Entity::DepthOffset

Get/Set the depth-offset of the entity. This value is added to the Y Position of the entity, which is then used to determine the rendering order of each entity. Default value is 0 for all entities.

This code explains how this variable works.
entity1.Position.Y -- => 50
entity2.Position.Y -- => 45
-- Entity1 is rendered in front of Entity2

entity1.DepthOffset = -10
-- new Entity1 renderYPosition => 40
-- Entity2 is rendered in front of Entity1

◆ DropSeed

const integer Entity::DropSeed

Get/set the Seed of the Drop RNG.

◆ EntityCollisionClass

EntityCollisionClass Entity::EntityCollisionClass

◆ FlipX

boolean Entity::FlipX

◆ FrameCount

const integer Entity::FrameCount

◆ Friction

float Entity::Friction

loaded from entity config

◆ GridCollisionClass

GridCollisionClass Entity::GridCollisionClass

◆ HitPoints

float Entity::HitPoints
The HitPoints value is not decremented immediately upon taking damage like you would expect. Rather, it is only updated on the frame after the entity takes damage.

◆ Index

const integer Entity::Index

◆ InitSeed

const integer Entity::InitSeed

◆ Mass

float Entity::Mass

◆ MaxHitPoints

float Entity::MaxHitPoints

◆ Parent

Entity& Entity::Parent

◆ Position

Vector Entity::Position

◆ PositionOffset

const Vector& Entity::PositionOffset

◆ RenderZOffset

integer Entity::RenderZOffset
This variable doesnt seem to do anything useful. Use DepthOffset instead.

◆ SizeMulti

Vector Entity::SizeMulti

◆ SpawnerEntity

Entity& Entity::SpawnerEntity

◆ SpawnerType

EntityType Entity::SpawnerType

◆ SpawnerVariant

integer Entity::SpawnerVariant

◆ SpawnGridIndex

const integer Entity::SpawnGridIndex

◆ SplatColor

const Color& Entity::SplatColor

◆ SpriteOffset

const Vector& Entity::SpriteOffset

◆ SpriteRotation

float Entity::SpriteRotation

◆ SpriteScale

const Vector& Entity::SpriteScale

◆ SubType

integer Entity::SubType

◆ Target

Entity& Entity::Target

◆ TargetPosition

const Vector& Entity::TargetPosition

◆ Type

const EntityType Entity::Type

◆ Variant

integer Entity::Variant

◆ Velocity

Vector Entity::Velocity

◆ Visible

boolean Entity::Visible

◆ Size

float Entity::Size
Returns the size of the hitbox on an entity.