Binding of Isaac - Afterbirth+ Lua Reference/Guide
Game Class Reference

Public Member Functions

 Update ()
 
 Render ()
 
boolean IsPaused ()
 Displays the HUD elements that are moved to the gamepad. More...
 
EntitySpawn (EntityType Type, integer Variant, Vector Position, Vector Velocity, Entity Spawner, integer SubType, integer Seed)
 
EntityNPCSpawnEntityDesc (Entity::EntityDesc desc, Vector Position, Entity Spawner)
 
 BombDamage (Vector Position, float Damage, float Radius, boolean LineCheck, Entity Source, integer TearFlags, integer DamageFlags, boolean DamageSource)
 
 BombExplosionEffects (Vector Position, float Damage, integer TearFlags, Color Color, Entity Source, float RadiusMult, boolean LineCheck, boolean DamageSource)
 The complete bomb explosion package: Do damage, spawn boomgraphics, and apply tearflag-based effects. More...
 
 BombTearflagEffects (Vector Position, float Radius, integer TearFlags, Entity Source)
 Does bomb-exclusive special effects. More...
 
 Fart (Vector Position, float Radius, Entity Source, float FartScale, integer FartSubType)
 
 CharmFart (Vector Position, float Radius, Entity Source)
 
 ButterBeanFart (Vector Position, float Radius, Entity Source, boolean ShowEffect)
 
boolean RerollEnemy (Entity e)
 
 SpawnParticles (Vector Pos, EntityEffect::Variant ParticleType, integer NumParticles, float Speed, Color Color, float Height)
 
FontGetFont ()
 
LevelGetLevel ()
 
RoomGetRoom ()
 
EntityPlayerGetPlayer (integer Index)
 
EntityPlayerGetNearestPlayer (Vector Pos)
 
EntityPlayerGetRandomPlayer (Vector Pos, float Radius)
 
integer GetNumPlayers ()
 
History & GetItemHistory ()
 
ItemPoolGetItemPool ()
 
ItemOverlay & GetItemOverlay ()
 
SeedsGetSeeds ()
 
 End (Ending Ending)
 
 ShowFortune ()
 
 ShowRule ()
 
 StartRoomTransition (integer RoomIndex, Direction Direction, RoomTransition::Animation Animation)
 
 ChangeRoom (integer RoomIndex)
 
 StartStageTransition (boolean SameStage, StageTransition::Animation Animation)
 
 MoveToRandomRoom (boolean IAmErrorRoom, integer Seed)
 
integer GetFrameCount ()
 
boolean GetStateFlag (StateFlag StateFlag)
 
 SetStateFlag (StateFlag StateFlag, boolean Val)
 
 SetLastDevilRoomStage (LevelStage Stage)
 
LevelStage (UserData) GetLastDevilRoomStage ()
 
 AddTreasureRoomsVisited ()
 
integer GetTreasureRoomVisitCount ()
 
 AddStageWithoutHeartsPicked ()
 
 ClearStagesWithoutHeartsPicked ()
 
integer GetStagesWithoutHeartsPicked ()
 
 AddStageWithoutDamage ()
 
 ClearStagesWithoutDamage ()
 
integer GetStagesWithoutDamage ()
 
 AddDevilRoomDeal ()
 
 DonateGreed (integer Donate)
 
 DonateAngel (integer Donate)
 
integer GetDevilRoomDeals ()
 
integer GetDonationModGreed ()
 
integer GetDonationModAngel ()
 
 ClearDonationModGreed ()
 
 ClearDonationModAngel ()
 
 SetLastLevelWithDamage (LevelStage Stage)
 
LevelStage GetLastLevelWithDamage ()
 
 AddEncounteredBoss (EntityType Boss, integer Variant)
 
integer GetNumEncounteredBosses ()
 
boolean HasEncounteredBoss (EntityType Boss, integer Variant)
 
integer GetGreedWavesNum ()
 
integer GetGreedBossWaveNum ()
 
 SetLastLevelWithoutHalfHp (LevelStage Stage)
 
LevelStage GetLastLevelWithoutHalfHp ()
 
 ShakeScreen (integer Timeout)
 
const integer & GetScreenShakeCountdown ()
 
 Darken (float Darkness, integer Timeout)
 
float GetDarknessModifier ()
 
float GetTargetDarkness ()
 
integer GetVictoryLap ()
 
 NextVictoryLap ()
 
boolean IsGreedMode ()
 
 RerollLevelCollectibles ()
 
 RerollLevelPickups (integer Seed)
 
 FinishChallenge ()
 
 AddPixelation (integer Duration)
 
 ShowHallucination (integer FrameCount, Backdrop::Backdrop HallucinationBackdrop)
 
integer HasHallucination ()
 
 UpdateStrangeAttractor (Vector Position)
 
Ambush & GetAmbush ()
 
 Fadein (float Speed)
 
 Fadeout (float Speed, FadeoutTarget Target)
 

Public Attributes

integer BossRushParTime
 Number of frames of game time. More...
 
integer BlueWombParTime
 
const VectorScreenShakeOffset
 
Challenge Challenge
 
const Difficulty Difficulty
 
integer TimeCounter
 same as FrameCounter but can be modified, mostly used for timed events (bossrush, daily, ...) and not for timestepping More...
 

Member Function Documentation

◆ AddDevilRoomDeal()

Game::AddDevilRoomDeal ( )

◆ AddEncounteredBoss()

Game::AddEncounteredBoss ( EntityType  Boss,
integer  Variant 
)

◆ AddPixelation()

Game::AddPixelation ( integer  Duration)

Triggers the effect of the "retro vision" pill.

◆ AddStageWithoutDamage()

Game::AddStageWithoutDamage ( )

Increases the ingame counter, that keeps track of the stages you cleared without taking damage. (useful for Devil deal manipulations)

◆ AddStageWithoutHeartsPicked()

Game::AddStageWithoutHeartsPicked ( )

Increases the ingame counter, that keeps track of stages you cleared without picking up hearts.

◆ AddTreasureRoomsVisited()

Game::AddTreasureRoomsVisited ( )

◆ BombDamage()

Game::BombDamage ( Vector  Position,
float  Damage,
float  Radius,
boolean  LineCheck,
Entity  Source,
integer  TearFlags,
integer  DamageFlags,
boolean  DamageSource 
)

◆ BombExplosionEffects()

Game::BombExplosionEffects ( Vector  Position,
float  Damage,
integer  TearFlags,
Color  Color,
Entity  Source,
float  RadiusMult,
boolean  LineCheck,
boolean  DamageSource 
)

The complete bomb explosion package: Do damage, spawn boomgraphics, and apply tearflag-based effects.

◆ BombTearflagEffects()

Game::BombTearflagEffects ( Vector  Position,
float  Radius,
integer  TearFlags,
Entity  Source 
)

Does bomb-exclusive special effects.

◆ ButterBeanFart()

Game::ButterBeanFart ( Vector  Position,
float  Radius,
Entity  Source,
boolean  ShowEffect 
)

◆ ChangeRoom()

Game::ChangeRoom ( integer  RoomIndex)

◆ CharmFart()

Game::CharmFart ( Vector  Position,
float  Radius,
Entity  Source 
)

◆ ClearDonationModAngel()

Game::ClearDonationModAngel ( )

◆ ClearDonationModGreed()

Game::ClearDonationModGreed ( )

◆ ClearStagesWithoutDamage()

Game::ClearStagesWithoutDamage ( )

Sets the counter for stages cleared without damage to 0.

◆ ClearStagesWithoutHeartsPicked()

Game::ClearStagesWithoutHeartsPicked ( )

Sets the counter for stages cleared without picking up hearts to 0.

◆ Darken()

Game::Darken ( float  Darkness,
integer  Timeout 
)

◆ DonateAngel()

Game::DonateAngel ( integer  Donate)

◆ DonateGreed()

Game::DonateGreed ( integer  Donate)

◆ End()

Game::End ( Ending  Ending)

remove entity from the update list (render only) void EnableEntity(Entity* e); add entity back to the update list (update + render) void DisableEntity(Entity* e);

◆ Fadein()

Game::Fadein ( float  Speed)

◆ Fadeout()

Game::Fadeout ( float  Speed,
FadeoutTarget  Target 
)

◆ Fart()

Game::Fart ( Vector  Position,
float  Radius,
Entity  Source,
float  FartScale,
integer  FartSubType 
)

◆ FinishChallenge()

Game::FinishChallenge ( )

◆ GetAmbush()

Ambush& Game::GetAmbush ( )

◆ GetDarknessModifier()

float Game::GetDarknessModifier ( )

◆ GetDevilRoomDeals()

integer Game::GetDevilRoomDeals ( )

◆ GetDonationModAngel()

integer Game::GetDonationModAngel ( )

Get the value that indicates the angel-counter of a shop-donation maschine. This Stat increases everytime you donate to a shop. A higher number grants a few advantages.

◆ GetDonationModGreed()

integer Game::GetDonationModGreed ( )

◆ GetFont()

Font& Game::GetFont ( )

◆ GetFrameCount()

integer Game::GetFrameCount ( )

Returns the number of frames the gameplay is actively running. Pauses are therefore not included!

1 second equals 30 frames.

This function therefore works drastically different than Isaac.GetFrameCount()

This code returns hours, minutes, seconds, and milliseconds of the game running actively:
local curTime = Game():GetFrameCount()
local msecs= curTime%30 * (10/3) -- turns the millisecond value range from [0 to 30] to [0 to 100]
local secs= math.floor(curTime/30)%60
local mins= math.floor(curTime/30/60)%60
local hours= math.floor(curTime/30/60/60)%60

◆ GetGreedBossWaveNum()

integer Game::GetGreedBossWaveNum ( )

◆ GetGreedWavesNum()

integer Game::GetGreedWavesNum ( )

◆ GetItemHistory()

History& Game::GetItemHistory ( )

◆ GetItemOverlay()

ItemOverlay& Game::GetItemOverlay ( )

◆ GetItemPool()

ItemPool& Game::GetItemPool ( )

◆ GetLastDevilRoomStage()

LevelStage (UserData) Game::GetLastDevilRoomStage ( )

Since it returns UserData, this function is unusable and therefore broken.

◆ GetLastLevelWithDamage()

LevelStage Game::GetLastLevelWithDamage ( )

◆ GetLastLevelWithoutHalfHp()

LevelStage Game::GetLastLevelWithoutHalfHp ( )

◆ GetLevel()

Level& Game::GetLevel ( )

◆ GetNearestPlayer()

EntityPlayer& Game::GetNearestPlayer ( Vector  Pos)

◆ GetNumEncounteredBosses()

integer Game::GetNumEncounteredBosses ( )

◆ GetNumPlayers()

integer Game::GetNumPlayers ( )

◆ GetPlayer()

EntityPlayer& Game::GetPlayer ( integer  Index)

◆ GetRandomPlayer()

EntityPlayer& Game::GetRandomPlayer ( Vector  Pos,
float  Radius 
)

◆ GetRoom()

Room& Game::GetRoom ( )

◆ GetScreenShakeCountdown()

const integer& Game::GetScreenShakeCountdown ( )

◆ GetSeeds()

Seeds& Game::GetSeeds ( )

◆ GetStagesWithoutDamage()

integer Game::GetStagesWithoutDamage ( )

◆ GetStagesWithoutHeartsPicked()

integer Game::GetStagesWithoutHeartsPicked ( )

◆ GetStateFlag()

boolean Game::GetStateFlag ( StateFlag  StateFlag)

◆ GetTargetDarkness()

float Game::GetTargetDarkness ( )

◆ GetTreasureRoomVisitCount()

integer Game::GetTreasureRoomVisitCount ( )

◆ GetVictoryLap()

integer Game::GetVictoryLap ( )

◆ HasEncounteredBoss()

boolean Game::HasEncounteredBoss ( EntityType  Boss,
integer  Variant 
)

◆ HasHallucination()

integer Game::HasHallucination ( )

◆ IsGreedMode()

boolean Game::IsGreedMode ( )

◆ IsPaused()

boolean Game::IsPaused ( )

Returns true, if the game is in a state, where the player is unable to input any thing or the game logic is paused. This includes hiving the pause menu opened, being in room transitions/cutscenes or while displaying a "big book" animation.

◆ MoveToRandomRoom()

Game::MoveToRandomRoom ( boolean  IAmErrorRoom,
integer  Seed 
)

◆ NextVictoryLap()

Game::NextVictoryLap ( )

◆ Render()

Game::Render ( )

◆ RerollEnemy()

boolean Game::RerollEnemy ( Entity  e)

◆ RerollLevelCollectibles()

Game::RerollLevelCollectibles ( )

◆ RerollLevelPickups()

Game::RerollLevelPickups ( integer  Seed)

◆ SetLastDevilRoomStage()

Game::SetLastDevilRoomStage ( LevelStage  Stage)

◆ SetLastLevelWithDamage()

Game::SetLastLevelWithDamage ( LevelStage  Stage)

◆ SetLastLevelWithoutHalfHp()

Game::SetLastLevelWithoutHalfHp ( LevelStage  Stage)

◆ SetStateFlag()

Game::SetStateFlag ( StateFlag  StateFlag,
boolean  Val 
)

◆ ShakeScreen()

Game::ShakeScreen ( integer  Timeout)

◆ ShowFortune()

Game::ShowFortune ( )

◆ ShowHallucination()

Game::ShowHallucination ( integer  FrameCount,
Backdrop::Backdrop  HallucinationBackdrop 
)

Plays the Delirium animation (Static noise intersected with past gameplay fotage), which will also change the background of the current room.

This function does not work and will crash your game on use!

This code emulated the effect of this function by hijacking the Delirious item effect
local usagetime = -1 -- stores the last time the effect was called.

-- call this function to play the Hallucination effect
function playHallucination()
    local player = Isaac.GetPlayer(0)
    usagetime = Game().TimeCounter
    player:UseActiveItem(510, false, false, false, false) -- use the delirious item without applying the costume
    player:GetEffects():RemoveCollectibleEffect(510) -- remove any unwanted side effects of the item usage
end

-- Removes all spawned NPC entities when activating the function
function mod:onFriendlyInit(npc) 
	if Game().TimeCounter-usagetime == 0 then -- only remove enemies that spawned when the effect was called!
		npc:Remove()
	end
end
mod:AddCallback(ModCallbacks.MC_POST_NPC_INIT, mod.onFriendlyInit)

◆ ShowRule()

Game::ShowRule ( )

◆ Spawn()

Entity& Game::Spawn ( EntityType  Type,
integer  Variant,
Vector  Position,
Vector  Velocity,
Entity  Spawner,
integer  SubType,
integer  Seed 
)

The game has two spawn functions, Game():Spawn() (this one) and Isaac.Spawn(). If you need to spawn something with a specific seed, then you use Game():Spawn(). If you need to spawn something with a randomly generated seed, then use Isaac.Spawn(). Most of the time, you will probably want to use Isaac.Spawn().

This code spawns a Leech with specific seed.
Game():Spawn(
  EntityType.ENTITY_LEECH, -- Type
  0, -- Variant
  Game():GetRoom():GetCenterPos(), -- Position
  Vector(0, 0), -- Velocity
  nil, -- Parent
  0, -- SubType
  Game():GetRoom():GetSpawnSeed() -- Seed (the "GetSpawnSeed()" function gets a reproducible seed based on the room, e.g. "2496979501")
)

◆ SpawnEntityDesc()

EntityNPC& Game::SpawnEntityDesc ( Entity::EntityDesc  desc,
Vector  Position,
Entity  Spawner 
)

◆ SpawnParticles()

Game::SpawnParticles ( Vector  Pos,
EntityEffect::Variant  ParticleType,
integer  NumParticles,
float  Speed,
Color  Color,
float  Height 
)

◆ StartRoomTransition()

Game::StartRoomTransition ( integer  RoomIndex,
Direction  Direction,
RoomTransition::Animation  Animation 
)
Available Animation types (Discovered by "ilise rose" (@yatboim)):
  • 0: (Default) Standard transition, sweeps the room in from a direction
  • 1: (Fade) Fade to black transition, like its used for the "goto" - console command
  • 2: (Stage) Pixel out transition, like used for crawlspaces and the trapdoor at the end of floors
  • 3: (Teleport) teleport transition, isaac teleports out of the current room and into the next
  • 5: (Ankh) Same as standard transition
  • 6: (Dead Cat) Same as standard transition
  • 7: (1Up) Same as standard transition
  • 8: (Guppys Collar) Same as standard transition
  • 9: (Judas Shadow) Same as standard transition
  • 10: (Lazarus Rags) Same as standard transition
  • 12: (Glowing Hourglass) Same as standard transition
  • 13: (D7) Same as standard transition
  • 14: (Missing Poster) Same as standard transition
The Direction variable is completely ignored at all times, with the game instead calculating the direction between the two rooms itself for the animation. The two rooms are the current room and the room of the RoomIndex. It has no impact on the doors either.

◆ StartStageTransition()

Game::StartStageTransition ( boolean  SameStage,
StageTransition::Animation  Animation 
)

Starts a transition animation like it`s playing when entering a trapdoor to switch between stages.

Stage Transition types:

  • 0: Standard transition. Removes the playermodel before the pixel fadeout. Then plays the Stage Nightmare animation. The player starts in fetal position after the transition.
  • 1: Standard transition with pixel fadein/out, nightmare cutscene but the player model doesnt get removed and starts in the normal standing position after the transition.
  • >2: Same as 0

◆ Update()

Game::Update ( )

◆ UpdateStrangeAttractor()

Game::UpdateStrangeAttractor ( Vector  Position)

Member Data Documentation

◆ BlueWombParTime

integer Game::BlueWombParTime

◆ BossRushParTime

integer Game::BossRushParTime

Number of frames of game time.

◆ Challenge

Challenge Game::Challenge

◆ Difficulty

const Difficulty Game::Difficulty

◆ ScreenShakeOffset

const Vector& Game::ScreenShakeOffset

◆ TimeCounter

integer Game::TimeCounter

same as FrameCounter but can be modified, mostly used for timed events (bossrush, daily, ...) and not for timestepping