Class "Isaac"

Functions

AddCallback () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void AddCallback ( table ref, int callbackId, table callbackFn, int entityId ) {: .copyable aria-label='Functions' }

AddPillEffectToPool () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int AddPillEffectToPool ( int pillEffect ) {: .copyable aria-label='Functions' }

returns pill color

ConsoleOutput () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void ConsoleOutput ( string text ) {: .copyable aria-label='Functions' }

Prints a string into the Debug Console

???- example "Example Code" You can use this example as an alternative.

    Isaac.ConsoleOutput("This is a Test.")
    -- Output: This is a Test.

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

CountBosses () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int CountBosses ( ) {: .copyable aria-label='Functions' }

Returns the number of bosses in the current room.

CountEnemies () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int CountEnemies ( ) {: .copyable aria-label='Functions' }

Returns the number of enemies in the current room.

CountEntities () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int CountEntities ( Entity Spawner, int Type, int Variant, int Subtype ) {: .copyable aria-label='Functions' }

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

DebugString () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void DebugString ( string str ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code prints :::lua "This is a Test." in the log.txt file.

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

ExecuteCommand () {: aria-label='Functions' }

{: .abp .tooltip .badge }

string ExecuteCommand ( string command ) {: .copyable aria-label='Functions' }

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

Explode () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void Explode ( Vector pos, Entity source, float damage ) {: .copyable aria-label='Functions' }

Spawn an explosion on a specified location.

FindByType () {: aria-label='Functions' }

{: .abp .tooltip .badge }

table FindByType ( int Type, int Variant, int Subtype, boolean Cache, boolean IgnoreFriendly ) {: .copyable aria-label='Functions' }

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.

FindInRadius () {: aria-label='Functions' }

{: .abp .tooltip .badge }

table FindInRadius ( Vector Position, float Radius, int Partitions ) {: .copyable aria-label='Functions' }

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.

GetCardIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetCardIdByName ( string cardHudName ) {: .copyable aria-label='Functions' }

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

???- note "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 "Example Code" This code gets the CardID of XVI - The Tower.

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

GetChallenge () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetChallenge ( ) {: .copyable aria-label='Functions' }

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

GetChallengeIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetChallengeIdByName ( string challengeName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the ChallengeID of Aprils fool.

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

GetCostumeIdByPath () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetCostumeIdByPath ( string path ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the CostumeID of the Poop transformation costume.

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

GetCurseIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetCurseIdByName ( string curseName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the CurseID of Curse of the Unknown.

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

GetEntityTypeByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetEntityTypeByName ( string entityName ) {: .copyable aria-label='Functions' }

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

???- note "Notes" There is no SubType version of this function.

???- example "Example Code" This code gets the EntityType of Flaming Gaper.

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

GetEntityVariantByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetEntityVariantByName ( string entityName ) {: .copyable aria-label='Functions' }

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

???- note "Notes" There is no SubType version of this function.

???- example "Example Code" This code gets the variant of Flaming Gaper.

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

GetFrameCount () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetFrameCount ( ) {: .copyable aria-label='Functions' }

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 :::lua Game():GetFrameCount()Link

GetFreeNearPosition () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector GetFreeNearPosition ( Vector pos, float step ) {: .copyable aria-label='Functions' }

GetItemConfig () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Config GetItemConfig ( ) {: .copyable aria-label='Functions' }

Returns the ItemConfig::Config object.

GetItemIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetItemIdByName ( string itemName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the ItemID of Brimstone.

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

GetMusicIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetMusicIdByName ( string musicName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the MusicID of the Title Screen.

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

GetPillEffectByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetPillEffectByName ( string pillEffect ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the PillEffectID of I can see forever!.

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

GetPlayer () {: aria-label='Functions' }

{: .abp .tooltip .badge }

EntityPlayer GetPlayer ( int playerId ) {: .copyable aria-label='Functions' }

Returns the EntityPlayer which the user is controlling. 0 = Main player. Higher numbers refer to coop babies.

???- example "Example Code"

    Isaac.GetPlayer(0)

GetPlayerTypeByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetPlayerTypeByName ( string playerName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the PlayerType of Azazel.

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

GetRandomPosition () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector GetRandomPosition ( ) {: .copyable aria-label='Functions' }

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

GetRoomEntities () {: aria-label='Functions' }

{: .abp .tooltip .badge }

table GetRoomEntities ( ) {: .copyable aria-label='Functions' }

Returns a table containing all entities in the room.

GetSoundIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetSoundIdByName ( string soundName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the SoundEffectID of a sound named "Custom Sound Effect"

    Isaac.GetSoundIdByName("Custom Sound Effect")

GetTextWidth () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetTextWidth ( string str ) {: .copyable aria-label='Functions' }

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

GetTime () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetTime ( ) {: .copyable aria-label='Functions' }

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

GetTrinketIdByName () {: aria-label='Functions' }

{: .abp .tooltip .badge }

int GetTrinketIdByName ( string trinketName ) {: .copyable aria-label='Functions' }

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

???- example "Example Code" This code gets the TrinketType of Lucky Toe.

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

GridSpawn () {: aria-label='Functions' }

{: .abp .tooltip .badge }

GridEntity GridSpawn ( GridEntity gridEntityType, int Variant, Vector position, boolean forced ) {: .copyable aria-label='Functions' }

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

???+ bug "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.

HasModData () {: aria-label='Functions' }

{: .abp .tooltip .badge }

boolean HasModData ( table ref ) {: .copyable aria-label='Functions' }

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.

LoadModData () {: aria-label='Functions' }

{: .abp .tooltip .badge }

string LoadModData ( table ref ) {: .copyable aria-label='Functions' }

Returns a JSON array/table 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.

???- example "Example Code" This code loads data stored in the "saveX.dat" file, if it exists.

    local yourMod = RegisterMod("someMod", 1)
    local json = require("json")
    -- ...
    function yourMod:OnGameStart(isSave)
        --Loading Moddata--
        if yourMod:HasData() then
            local myTable = json.decode(Isaac.LoadModData(yourMod))
        end
    end
    yourMod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, yourMod.OnGameStart)

RegisterMod () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void RegisterMod ( table ref, string modName, int apiVersion ) {: .copyable aria-label='Functions' }

Method to define a mod in the game. THIS NEEDS TO BE DEFINED IN EVERY MOD!

???- example "Example Code"

    local yourMod = RegisterMod("someMod", 1)

RemoveCallback () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void RemoveCallback ( table ref, int callbackId, table callbackFn ) {: .copyable aria-label='Functions' }

RemoveModData () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void RemoveModData ( table ref ) {: .copyable aria-label='Functions' }

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.

RenderScaledText () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void RenderScaledText ( string str, float X, float Y, float ScaleX, float ScaleY, float R, float G, float B, float A ) {: .copyable aria-label='Functions' }

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 "Example Code" This code renders the player position on the screen.

    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 )

RenderText () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void RenderText ( string str, float X, float Y, float R, float G, float B, float A ) {: .copyable aria-label='Functions' }

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 "Example Code" This code renders the player position on the screen.

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

SaveModData () {: aria-label='Functions' }

{: .abp .tooltip .badge }

void SaveModData ( table ref, string data ) {: .copyable aria-label='Functions' }

Stores a JSON array/table 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.

???- example "Example Code" This code saves a table in the "saveX.dat" file.

    local yourMod = RegisterMod("someMod", 1)
    local json = require("json")
    -- ...
    --Saving Moddata--
    function yourMod:SaveGame()
    local table= {1,2,3}
    yourMod.SaveData(yourMod, json.encode(table))
    end
    yourMod:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, yourMod.SaveGame)

ScreenToWorld () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector ScreenToWorld ( Vector pos ) {: .copyable aria-label='Functions' }

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).

ScreenToWorldDistance () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector ScreenToWorldDistance ( Vector pos ) {: .copyable aria-label='Functions' }

Spawn () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Entity Spawn ( int entityType, int entityVariant, int entitySubtype, Vector position, Vector velocity, Entity Spawner ) {: .copyable aria-label='Functions' }

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 "Example Code" This code spawns a random collectible at in center of the current room.

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

WorldToRenderPosition () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector WorldToRenderPosition ( Vector pos ) {: .copyable aria-label='Functions' }

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.

WorldToScreen () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector WorldToScreen ( Vector pos ) {: .copyable aria-label='Functions' }

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 "Example Code" This code render "test" at the position of the player. The text will move with isaac.

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

WorldToScreenDistance () {: aria-label='Functions' }

{: .abp .tooltip .badge }

Vector WorldToScreenDistance ( Vector pos ) {: .copyable aria-label='Functions' }

Last updated