Skip to content

Class "Isaac"⚓︎

Info

When accessing the methods of the Isaac class, you need to use a . (period) instead of a : (colon)!

For example:

1
local player = Isaac.GetPlayer()

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


Add·Priority·Callback ()⚓︎

void AddPriorityCallback ( table modRef, function callbackId, CallbackPriority priority, table callbackFn, int entityId )⚓︎


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, EntityType Type = EntityType.ENTITY_NULL, int Variant = -1, int SubType = -1 )⚓︎

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 %systemdrive%\Users\%username%\Documents\My Games\Binding of Isaac Repentance\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: [INFO] - 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 ( EntityType Type, int Variant = -1, int SubType = -1, boolean Cache = false, boolean IgnoreFriendly = false )⚓︎

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 = 0xFFFFFFFF )⚓︎

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·Built·In·Callback·State ()⚓︎

boolean GetBuiltInCallbackState ( function callbackId )⚓︎


Get·Callbacks ()⚓︎

table GetCallbacks ( function callbackId, boolean createIfMissing )⚓︎


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

int GetCardIdByName ( string cardHudName )⚓︎

Returns the CardID based on the "hud"-attribute defined in the "pocketitems.xml" file. Returns -1 if no card with that "hud" attribute value could be found.

Warning

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

Bug

This function does not work for vanilla cards/runes, because they don't have the "hud" attribute defined in their entry in the pocketitems.xml file. You need to use the Card enum to get those vanilla IDs instead.

Example Code

This code gets the CardID of a modded card.

1
2
3
<pocketitems>
    <card type="tarot" pickup="1" description="some description"  name="My new card" hud="my_modded_card" />
</pocketitems>
1
Isaac.GetCardIdByName("my_modded_card")


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) Returns -1 if no challenge with that name could be found (Case sensitive).

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) Returns -1 if no costume with that path could be found.

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) Returns -1 if no curse with that name could be found.

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) Returns 0 if no entity with that name could be found.

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) Returns -1 if no entity with that name could be found.

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 ()⚓︎

ItemConfig GetItemConfig ( )⚓︎

This is the only way to access the ItemConfig object.


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

int GetItemIdByName ( string itemName )⚓︎

Returns the ItemID of a Collectible. (File: items.xml) Returns -1 if no item with that name could be found.

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) Returns -1 if no music with that name could be found.

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) Returns -1 if no pill with that name could be found.

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 = 0 )⚓︎

Returns the EntityPlayer that matches the provided player ID. Player IDs start at 0 and increment upwards. For example, when playing as Jacob & Esau, Jacob will have a player ID of 0 and Esau will have a player ID of 1.

If an invalid player ID is passed (such as -20 or 20), the function will instead assume a player index of 0.

This function can return nil if it is called before any player is initialized (i.e. if you call it in the main menu).

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

Example Code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
local function getPlayers()
  local game = Game()
  local numPlayers = game:GetNumPlayers()

  local players = {}
  for i = 0, numPlayers - 1 do
    local player = Isaac.GetPlayer(i)
    table.insert(players, player)
  end

  return players
end

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

PlayerType GetPlayerTypeByName ( string playerName , boolean Tainted = false )⚓︎

Returns the PlayerType (ID) of a character based on its name. (File: players.xml) Returns -1 if no player with that name could be found.

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 an iterable table containing all entities in the room at the time the function was called.

This behavior is different to Room::GetEntities(), which returns a raw pointer to the array that stores all entities of the room at any given time. For most usecases, its advised to use Isaac.GetRoomEntities()!

Example Code

This code prints the Type, Variant and SubType of each entity in the room.

1
2
3
for i, entity in ipairs(Isaac.GetRoomEntities()) do
    print(entity.Type, entity.Variant, entity.SubType)
end

Get·Screen·Height ()⚓︎

float GetScreenHeight ( )⚓︎


Get·Screen·Point·Scale ()⚓︎

float GetScreenPointScale ( )⚓︎


Get·Screen·Width ()⚓︎

float GetScreenWidth ( )⚓︎


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

int GetSoundIdByName ( string soundName )⚓︎

Returns the SoundEffectID of a sound based on its name. (File: sounds.xml) Returns -1 if no sound with that name could be found.

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 time in milliseconds since the computer's operating system was started.

This is useful for measuring how much real time has passed independent of how many frames have passed. (Frames are not a very good indicator of how much time has passed, because the game locks up to load new data on every level transition and room transition.)

For example, you could use this to implement an on-screen speedrunning timer based on real-time, or to benchmark the performance impact of one function over another.


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

int GetTrinketIdByName ( string trinketName )⚓︎

Returns the TrinketType of a trinket based on its name. (File: items.xml) Returns -1 if no trinket with that name could be found.

Example Code

This code gets the TrinketType of Lucky Toe.

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

Grid·Spawn ()⚓︎

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

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

Bugs

The "forced" argument has no effect and will not override the grid entity at the given location. Instead, remove the grid entity at the given location if nessesary before spawning something on top of it.

For example, to spawn a super secret rock in the center of the room:

1
2
3
4
local game = Game()
local room = game:GetRoom()
local centerPos = room:GetCenterPos()
Isaac.GridSpawn(GridEntityType.GRID_ROCK_SS, 0, centerPos, true)

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. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

For AB+, they are stored inside their mod's folder next to the "main.lua" file.

For Repentance, They are stored in the "data" folder next to the "mods" folder inside the game files.

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. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

If you call this function in the main menu, it will return the save data for save slot 1 by default.

For AB+, they are stored inside their mod's folder next to the "main.lua" file.

For Repentance, They are stored in the "data" folder next to the "mods" folder inside the game files.

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()
local text = "X: " .. player.Position.X .. ", Y: " .. player.Position.Y
Isaac.RenderText(text, 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()
local pos = player.Position
Isaac.RenderText("X: "..pos.X.." Y: "..pos.Y, 50, 50, 1 ,1 ,1 ,1 )

Run·Callback ()⚓︎

void RunCallback ( function callbackId, table modRef )⚓︎


Run·Callback·With·Param ()⚓︎

void RunCallbackWithParam ( function callbackId, table modRef )⚓︎


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. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.

For AB+, they are stored inside their mod's folder next to the "main.lua" file.

For Repentance, They are stored in the "data" folder next to the "mods" folder inside the game files.

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 )⚓︎


Set·Built·In·Callback·State ()⚓︎

void SetBuiltInCallbackState ( function callbackId, boolean state )⚓︎


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.

Example Code

This code render "test" at the position of the mouse cursor independend on if the game is in full screen or not.

1
2
3
local mousePos = Input.GetMousePosition(true)
local renderpos = Isaac.WorldToRenderPosition(mousePos) * 2
Isaac.RenderText("test", renderpos.X, renderpos.Y, 1 ,1 ,1 ,1 )


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()
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: January 21, 2023