Skip to content

Class "Isaac"⚓︎

Functions⚓︎

Add·Callback ()⚓︎

void AddCallback ( table modRef, function callbackId, table callbackFn, int entityId )⚓︎

It is recommended to use the AddCallback function on a Mod Reference instead.


Add·Pill·Effect·To·Pool ()⚓︎

int AddPillEffectToPool ( int pillEffect )⚓︎

returns pill color


Console·Output ()⚓︎

void ConsoleOutput ( string text )⚓︎

Prints a string into the Debug Console

Example Code

You can use this example as an alternative.

1
2
3
4
5
6
Isaac.ConsoleOutput("This is a Test.")
-- Output: This is a Test.

-- Alternatively:
print("This is a Test.")
-- Output: This is a Test.


Count·Bosses ()⚓︎

int CountBosses ( )⚓︎

Returns the number of bosses in the current room.


Count·Enemies ()⚓︎

int CountEnemies ( )⚓︎

Returns the number of enemies in the current room.


Count·Entities ()⚓︎

int CountEntities ( Entity Spawner, int Type, int Variant, int Subtype )⚓︎

Returns the number of entities in the current room that fulfill the specified requirements. Spawner refers to an entity object (can be nil) Type refers to the found entity's type (Can be EntityType.ENTITY_NULL) Variant and Subtype refer to the found entitys Variant and Subtype (Can be -1)


Debug·String ()⚓︎

void DebugString ( string str )⚓︎

Prints a string into the log file. You can find this file here C:\Users\Jan\Documents\My Games\Binding of Isaac Afterbirth+\log.txt

Example Code

This code prints "This is a Test." in the log.txt file.

1
2
Isaac.DebugString("This is a Test.")
-- Output: Lua Debug: This is a Test.


Execute·Command ()⚓︎

string ExecuteCommand ( string command )⚓︎

This function executes a debug console command. see the Debug Console Tutorial for informations on how to use commands.


Explode ()⚓︎

void Explode ( Vector pos, Entity source, float damage )⚓︎

Spawn an explosion on a specified location.


Find·By·Type ()⚓︎

table FindByType ( int Type, int Variant, int Subtype, boolean Cache, boolean IgnoreFriendly )⚓︎

Returns entities based on Type, Variant, Subtype. If Variant and/or Subtype is -1 then everything is includedUse Cache flag for multiple calls per frame.


Find·In·Radius ()⚓︎

table FindInRadius ( Vector Position, float Radius, int Partitions )⚓︎

Returns entities in range of Radius from Position filtered by Partitions mask (see EntityPartition enum) (include all = 0xffffffff)

This function does not return the entities sorted by nearest first, but based on the order they were loaded.


Get·Card·Id·By·Name ()⚓︎

int GetCardIdByName ( string cardHudName )⚓︎

Returns the CardID based on its hud value. (File: pocketitems.xml)

Notes

The name of this function is misleading, this function will only work with the hud value of a card and not the name of a card.

Example Code

This code gets the CardID of XVI - The Tower.

1
2
Isaac.GetCardIdByName("16_TheTower")
--Returns: 17


Get·Challenge ()⚓︎

int GetChallenge ( )⚓︎

Returns the ID of a challenge the player is currently in. Returns 0 if the player is not playing any challenge.


Get·Challenge·Id·By·Name ()⚓︎

int GetChallengeIdByName ( string challengeName )⚓︎

Returns the ChallengeID of a challenge based on its name. (File: challenges.xml)

Example Code

This code gets the ChallengeID of Aprils fool.

1
2
Isaac.GetChallengeIdByName("Aprils fool")
--Returns: 32


Get·Costume·Id·By·Path ()⚓︎

int GetCostumeIdByPath ( string path )⚓︎

Returns the CostumeID of a costume based on its file path. (File: costumes2.xml)

Example Code

This code gets the CostumeID of the Poop transformation costume.

1
2
Isaac.GetCostumeIdByPath("gfx/characters/n027_Transformation_Poop.anm2")
--Returns: 27


Get·Curse·Id·By·Name ()⚓︎

int GetCurseIdByName ( string curseName )⚓︎

Returns the CurseID of a curse based on its name. (File: curses.xml)

Example Code

This code gets the CurseID of Curse of the Unknown.

1
2
Isaac.GetCurseIdByName("Curse of the Unknown")
--Returns: 4


Get·Entity·Type·By·Name ()⚓︎

int GetEntityTypeByName ( string entityName )⚓︎

Returns the EntityType of an entity based on its name. (File: entities2.xml)

Notes

There is no SubType version of this function.

Example Code

This code gets the EntityType of Flaming Gaper.

1
2
Isaac.GetEntityTypeByName("Flaming Gaper")
--Returns: 10


Get·Entity·Variant·By·Name ()⚓︎

int GetEntityVariantByName ( string entityName )⚓︎

Returns the variant of an entity based on its name. (File: entities2.xml)

Notes

There is no SubType version of this function.

Example Code

This code gets the variant of Flaming Gaper.

1
2
Isaac.GetEntityVariantByName("Flaming Gaper")
--Returns: 2


Get·Frame·Count ()⚓︎

int GetFrameCount ( )⚓︎

Returns the amount of frames the game as a whole is running. The counter increases even when the game is paused or when you are in the main menu! 1 second equals roughtly 60 frames. This function therefore works drastically different than Game():GetFrameCount()Link


Get·Free·Near·Position ()⚓︎

Vector GetFreeNearPosition ( Vector pos, float step )⚓︎


Get·Item·Config ()⚓︎

Config GetItemConfig ( )⚓︎

Returns the ItemConfig::Config object.


Get·Item·Id·By·Name ()⚓︎

int GetItemIdByName ( string itemName )⚓︎

Returns the ItemID of a Collectible. (File: items.xml)

Example Code

This code gets the ItemID of Brimstone.

1
2
Isaac.GetItemIdByName("Brimstone")
--Returns: 118


Get·Music·Id·By·Name ()⚓︎

int GetMusicIdByName ( string musicName )⚓︎

Returns the MusicID of a music track. (File: music.xml)

Example Code

This code gets the MusicID of the Title Screen.

1
2
Isaac.GetMusicIdByName("Title Screen")
--Returns: 61


Get·Pill·Effect·By·Name ()⚓︎

int GetPillEffectByName ( string pillEffect )⚓︎

Returns the PillEffectID based on its name. (File: pocketitems.xml)

Example Code

This code gets the PillEffectID of I can see forever!.

1
2
Isaac.GetPillEffectByName("I can see forever!")
--Returns: 23


Get·Player ()⚓︎

EntityPlayer GetPlayer ( int playerId )⚓︎

Returns the EntityPlayer which the user is controlling. 0 = Main player. Higher numbers refer to coop babies. If an index is given, that is not used, it will return the last player in the list.

This function can return nil if the function is called before any player is initialized.

This function is the same as Game():GetPlayer().

Example Code
1
Isaac.GetPlayer(0)

Get·Player·Type·By·Name ()⚓︎

int GetPlayerTypeByName ( string playerName )⚓︎

Returns the PlayerType of a character based on its name. (File: players.xml)

Example Code

This code gets the PlayerType of Azazel.

1
2
Isaac.GetPlayerTypeByName("Azazel")
--Returns: 7


Get·Random·Position ()⚓︎

Vector GetRandomPosition ( )⚓︎

Returns a random position inside the current room. The Return value is a Vector containing the position in world coordinates.


Get·Room·Entities ()⚓︎

table GetRoomEntities ( )⚓︎

Returns a table containing all entities in the room.


Get·Sound·Id·By·Name ()⚓︎

int GetSoundIdByName ( string soundName )⚓︎

Returns the SoundEffectID of a sound based on its name. (File: sounds.xml)

Example Code

This code gets the SoundEffectID of a sound named "Custom Sound Effect"

1
Isaac.GetSoundIdByName("Custom Sound Effect")


Get·Text·Width ()⚓︎

int GetTextWidth ( string str )⚓︎

Returns the width of the given string in pixels based on the "terminus8" font (same font as used in Isaac.RenderText())


Get·Time ()⚓︎

int GetTime ( )⚓︎

Returns the current game time in milliseconds. This includes pauses!


Get·Trinket·Id·By·Name ()⚓︎

int GetTrinketIdByName ( string trinketName )⚓︎

Returns the TrinketType of a trinket based on its name. (File: items.xml)

Example Code

This code gets the TrinketType of Lucky Toe.

1
2
Isaac.GetTrinketIdByName("Lucky Toe")
--Returns: 42


Grid·Spawn ()⚓︎

GridEntity GridSpawn ( GridEntity gridEntityType, int Variant, Vector position, boolean forced )⚓︎

Spawn a GridEntity at the given position (world coordinates).

Bugs

forced has no effect and will NOT override the grid entity at the given location. Remove a grid entity at the given location if nessesary before spawning something again.


Has·Mod·Data ()⚓︎

boolean HasModData ( table modRef )⚓︎

Returns "true" if your mod has Data stored using the "SaveModData()" function. Aka. if there is a "saveX.dat" file in your mod folder.There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

It is recommended to use the HasData function on a Mod Reference instead.


Load·Mod·Data ()⚓︎

string LoadModData ( table modRef )⚓︎

Returns a string that was stored in a "saveX.dat" file using the "SaveModData()" function. If there is no "saveX.dat" file in your mod, this function will return an empty string. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

It is recommended to use the LoadData function on a Mod Reference instead.


Register·Mod ()⚓︎

void RegisterMod ( table modRef, string modName, int apiVersion )⚓︎

Registers a table with the game to use as a Mod Reference.

It is recommended to use the global RegisterMod function instead.


Remove·Callback ()⚓︎

void RemoveCallback ( table modRef, function callbackId, table callbackFn )⚓︎

It is recommended to use the RemoveCallback function on a Mod Reference instead.


Remove·Mod·Data ()⚓︎

void RemoveModData ( table modRef )⚓︎

Deletes the stored "saveX.dat" file if it exists. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

It is recommended to use the RemoveData function on a Mod Reference instead.


Render·Scaled·Text ()⚓︎

void RenderScaledText ( string str, float X, float Y, float ScaleX, float ScaleY, float R, float G, float B, float A )⚓︎

Renders a scaled text on the Screen. X and Y coordinates need to be in screen coordinates ( x[0,~500) y [0,~350) ). ScaleX, ScaleY, R ,G ,B and A need to be between [0,1]. Some scale values can cause the font to display deformed and pixelated.

Example Code

This code renders the player position on the screen.

1
2
3
local player = Isaac.GetPlayer(0)
local pos = player.Position
Isaac.RenderText("X: "..pos.X.." Y: "..pos.Y, 50, 50, 0.5, 0.5, 1 ,1 ,1 ,1 )


Render·Text ()⚓︎

void RenderText ( string str, float X, float Y, float R, float G, float B, float A )⚓︎

Renders a text with the default size on the Screen. X and Y coordinates need to be in screen coordinates ( x[0,~500) y [0,~350) ). R,G,B and A need to be between [0,1].

Example Code

This code renders the player position on the screen.

1
2
3
local player = Isaac.GetPlayer(0)
local pos = player.Position
Isaac.RenderText("X: "..pos.X.." Y: "..pos.Y, 50, 50, 1 ,1 ,1 ,1 )


Save·Mod·Data ()⚓︎

void SaveModData ( table modRef, string data )⚓︎

Stores a string in a "saveX.dat" file. The stored Data persists thruout resets and game restart, so its perfect to store persistent data. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

It is recommended to use the SaveData function on a Mod Reference instead.


Screen·To·World ()⚓︎

Vector ScreenToWorld ( Vector pos )⚓︎

Transfers Screen (aka. Window coordinates) into Worldcoordinates. This can be used to get a specific location in the room in World coordnates The World coordinate system is x[0,inf) y[0,inf).


Screen·To·World·Distance ()⚓︎

Vector ScreenToWorldDistance ( Vector pos )⚓︎


Spawn ()⚓︎

Entity Spawn ( int entityType, int entityVariant, int entitySubtype, Vector position, Vector velocity, Entity Spawner )⚓︎

Spawns the defined entity at the given location. If the position is not free, it spawns it in the nearest free position. There are two spawn functions. Isaac.Spawn() and Game():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().

Example Code

This code spawns a random collectible at in center of the current room.

1
Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 0, Vector(320,280), Vector(0,0), nil)


World·To·Render·Position ()⚓︎

Vector WorldToRenderPosition ( Vector pos )⚓︎

Transfers world (aka. game coordinates) into Rendercoordinates. This can be used to render things at fixed positions in a room. The Render coordinate system is x[0,inf) y[0,inf). It defines the Position on the rendering-plane in the current room.


World·To·Screen ()⚓︎

Vector WorldToScreen ( Vector pos )⚓︎

Transfers world (aka. game coordinates) into Screen (aka. Window) coordinates. This can be used to render things next to an entity. The Screen coordinate system is x[0,inf) y[0,inf). Normally, it goes till ~500x ~300y. The return vector contains integer values or numbers ending with .5

Example Code

This code render "test" at the position of the player. The text will move with isaac.

1
2
3
local player = Isaac.GetPlayer(0)
local screenpos = Isaac.WorldToScreen(player.Position)  
Isaac.RenderText("test", screenpos.X, screenpos.Y, 1 ,1 ,1 ,1 )


World·To·Screen·Distance ()⚓︎

Vector WorldToScreenDistance ( Vector pos )⚓︎



Last update: June 9, 2021