Skip to content

Class "Level"⚓︎

Info

You can get this class by using the following functions:

Example Code
1
local level = Game():GetLevel()

Functions⚓︎

Add·Angel·Room·Chance ()⚓︎

void AddAngelRoomChance ( float Chance )⚓︎

Adds Chance to the Angel deal modifier. See GetAngelRoomChance for more information.


Add·Curse ()⚓︎

void AddCurse ( LevelCurse Curse, boolean ShowName )⚓︎

Info

As entries in curses.xml enumerate from 1 instead of 0, the LevelCurse bitmask value for a new curse must be acquired by doing 1 << (Isaac.GetCurseIdByName("...") - 1). This bitmask value is what's accepted by Level:AddCurse and the return value of MC_POST_CURSE_EVAL.


Apply·Blue·Map·Effect ()⚓︎

void ApplyBlueMapEffect ( )⚓︎


Apply·Compass·Effect ()⚓︎

void ApplyCompassEffect ( boolean Persistent )⚓︎


Apply·Map·Effect ()⚓︎

void ApplyMapEffect ( )⚓︎


Can·Open·Challenge·Room ()⚓︎

boolean CanOpenChallengeRoom ( int RoomIndex )⚓︎

Returns whether or not a Challenge Room door will be open. You must pass this method a valid grid index on the floor. It does not matter if the grid index is actually attached to the Challenge Room or not. This method will always return false if an invalid or a negative grid index is passed.


Can·Spawn·Devil·Room ()⚓︎

boolean CanSpawnDevilRoom ( )⚓︎


Can·Stage·Have·Curse·Of·Labyrinth ()⚓︎

boolean CanStageHaveCurseOfLabyrinth ( LevelStage Stage )⚓︎


Change·Room ()⚓︎

void ChangeRoom ( int RoomIndex, int Dimension = -1 )⚓︎

Bugs

This method does not update the fxlayers properly. Do not use this method and use Game.ChangeRoom instead.


Disable·Devil·Room ()⚓︎

void DisableDevilRoom ( )⚓︎


Force·Horseman·Boss ()⚓︎

boolean ForceHorsemanBoss ( int Seed )⚓︎

Returns true on success.


Get·Absolute·Stage ()⚓︎

LevelStage GetAbsoluteStage ( )⚓︎

In non-Greed Mode, returns the same thing as the GetStage() method. In Greed Mode, returns the adjusted stage similar to what it would be in non-Greed Mode.

For example:

  • On Greed Mode Basement, GetStage() returns 1, and GetAbsoluteStage() returns 1.
  • On Greed Mode Caves, GetStage() returns 2, and GetAbsoluteStage() returns 3.
  • On Greed mode Depths, GetStage() returns 3, and GetAbsoluteStage() returns 5.

Get·Angel·Room·Chance ()⚓︎

float GetAngelRoomChance ( )⚓︎

Gets the modifier value of the chance for this floor's deal to be an Angel room. Specifically, the actual effective chance for a deal to be an Angel room is 50% plus this value.

Info

If this value is above 0.0, deals can become Angel rooms even if a player has already taken a Devil deal item. If the chance is positive and a deal room has not spawned yet, the deal is guaranteed to be an Angel room.

Under normal circumstances, setting this value to below 0.0 will not reduce the chance for an Angel room, as values below 0.0 are usually ignored. A negative value will only affect Angel room chance if the player has an item that enables visiting Angel rooms even if a Devil deal has already been taken, such as Book of Virtues or Act of Contrition.


Get·Can·See·Everything ()⚓︎

boolean GetCanSeeEverything ( )⚓︎


Get·Current·Room ()⚓︎

Room GetCurrentRoom ( )⚓︎


Get·Current·Room·Desc ()⚓︎

const RoomDescriptor GetCurrentRoomDesc ( )⚓︎

This functions returns a read only version of the RoomDescriptor of the current room. If you want to edit the RoomDescriptor, use GetRoomByIdx() with GetCurrentRoomIndex() instead.

Example Code

This gets the current rooms RoomDescriptor class in read only and writeable versions.

1
2
3
local level = Game():GetLevel()
local readOnlyRoomDesc = level:GetCurrentRoomDesc()
local writeableRoomDesc = level:GetRoomByIdx(level:GetCurrentRoomIndex())


Get·Current·Room·Index ()⚓︎

int GetCurrentRoomIndex ( )⚓︎

Notes

This will always return the roomindex on the levelgrid, on which you entered the current room from. (see black entries in graphic below)

Room Grid indices


Get·Curse·Name ()⚓︎

string GetCurseName ( )⚓︎


Get·Curses ()⚓︎

int GetCurses ( )⚓︎


Get·Devil·Angel·Room·RNG ()⚓︎

RNG GetDevilAngelRoomRNG ( )⚓︎


Get·Dungeon·Placement·Seed ()⚓︎

int GetDungeonPlacementSeed ( )⚓︎


Get·Enter·Position ()⚓︎

Vector GetEnterPosition ( )⚓︎


Get·Heart·Picked ()⚓︎

boolean GetHeartPicked ( )⚓︎


Get·Last·Boss·Room·List·Index ()⚓︎

int GetLastBossRoomListIndex ( )⚓︎


Get·Last·Room·Desc ()⚓︎

const RoomDescriptor GetLastRoomDesc ( )⚓︎


Get·Name ()⚓︎

string GetName ( )⚓︎


Get·Non·Complete·Room·Index ()⚓︎

int GetNonCompleteRoomIndex ( )⚓︎


Get·Planetarium·Chance ()⚓︎

float GetPlanetariumChance ( )⚓︎

Returns the probability of getting a Planetarium (in the 0-1 range)


Get·Previous·Room·Index ()⚓︎

int GetPreviousRoomIndex ( )⚓︎


Get·Random·Room·Index ()⚓︎

int GetRandomRoomIndex ( boolean IAmErrorRoom, int Seed )⚓︎


Get·Room·By·Idx ()⚓︎

RoomDescriptor GetRoomByIdx ( int RoomIdx, int Dimension = -1 )⚓︎

Example Code

This gets the current rooms RoomDescriptor class.

1
2
local level = Game():GetLevel()
local curRoomDesc = level:GetRoomByIdx(level:GetCurrentRoomIndex())

Dimension Info

Dimension: ID of the dimension to get the room from

1
2
3
4
* -1: Current dimension
* 0: Main dimension
* 1: Secondary dimension, used by Downpour mirror dimension and Mines escape sequence
* 2: Death Certificate dimension
Warning

This function always returns a valid RoomDescriptor object, so error checking is recommended. The Data property of an invalid RoomDescriptor object is nil.


Get·Room·Count ()⚓︎

int GetRoomCount ( )⚓︎


Get·Rooms ()⚓︎

RoomDescriptor List GetRooms ( )⚓︎


Get·Stage ()⚓︎

LevelStage GetStage ( )⚓︎


Get·Stage·Type ()⚓︎

StageType GetStageType ( )⚓︎


Get·Starting·Room·Index ()⚓︎

int GetStartingRoomIndex ( )⚓︎

Returns the gridindex of the starting room of the current level.


Get·State·Flag ()⚓︎

boolean GetStateFlag ( LevelStateFlag LevelStateFlag)⚓︎


Has·Boss·Challenge ()⚓︎

boolean HasBossChallenge ( )⚓︎


Initialize·Devil·Angel·Room ()⚓︎

void InitializeDevilAngelRoom ( boolean ForceAngel, boolean ForceDevil )⚓︎

By calling this function, it "locks in" the choice between a Devil Room and an Angel Room for the current floor.

Once the room is initialized, the appropriate door will spawn after killing the boss.

This function still works to grant a Devil Room even if the player has the Eucharist.

Calling this function twice will have no effect, because the room will already have been initialized. For example, this means that if you force an Angel Room, you can't change it back to a Devil Room later on.

However, you can get around this restriction by calling level:GetRoomByIdx(GridRooms.ROOM_DEVIL_IDX).Data = nil, which will uninitialize the room.


Is·Alt·Stage ()⚓︎

boolean IsAltStage ( )⚓︎

Returns true if the level's StageType is not StageType.STAGE_ORIGINAL.


Is·Ascent ()⚓︎

boolean IsAscent ( )⚓︎

Returns true if the player is in the Ascent.


Is·Devil·Room·Disabled ()⚓︎

boolean IsDevilRoomDisabled ( )⚓︎


Is·Next·Stage·Available ()⚓︎

boolean IsNextStageAvailable ( )⚓︎

Returns false if on a final floor (Chest/Dark Room, The Void, Home). Returns true otherwise, including cases where the next stage is technically not available such as not having the Polaroid or Negative when entering its respective Big Chest or beating Hush for the first time.


Is·Pre·Ascent ()⚓︎

boolean IsPreAscent ( )⚓︎

Returns true if the player is in the version of Mausoleum/Gehenna II leading to the Ascent.


Make·Red·Room·Door ()⚓︎

boolean MakeRedRoomDoor ( int CurrentRoomIdx, DoorSlot Slot )⚓︎

Attempts to create a red room door in the given room at the given door slot. Returns true on success.

Notes

This function can be used to create rooms not connected to any other room. For example, calling MakeRedRoomDoor(2, DoorSlot.DOOR_LEFT0) will create a room where Slot of CurrentRoomIdx would connect to, in this case grid index 1.

Rooms can also be forced to be created by setting Challenge to Red Redemption (Challenge.CHALLENGE_RED_REDEMPTION). Note that creating a room connected to an otherwise invalid slot will cause the door to lead to an Error room!


Query·Room·Type·Index ()⚓︎

int QueryRoomTypeIndex ( RoomType RoomType, boolean Visited, RNG rng, boolean IgnoreGroup = false )⚓︎

IgnoreGroup: If set to true, includes rooms that do not have the same group ID as the current room (currently unused)


Remove·Compass·Effect ()⚓︎

void RemoveCompassEffect ( )⚓︎


Remove·Curses ()⚓︎

void RemoveCurses ( LevelCurse Curses )⚓︎

Curses: A bitmask of LevelCurse that indicates which curses will be removed

Example Code

This example removes curse of darkness and curse of the blind

1
Game():GetLevel():RemoveCurses(LevelCurse.CURSE_OF_DARKNESS | LevelCurse.CURSE_OF_BLIND)


Set·Can·See·Everything ()⚓︎

void SetCanSeeEverything ( boolean Value )⚓︎


Set·Heart·Picked ()⚓︎

void SetHeartPicked ( )⚓︎


Set·Next·Stage ()⚓︎

void SetNextStage ( )⚓︎

This function puts you in the next stage without applying any of the floor changes. For the changes to fully apply, either use the reseed console command, or Game.StartStageTransition.


Set·Red·Heart·Damage ()⚓︎

void SetRedHeartDamage ( )⚓︎


Set·Stage ()⚓︎

void SetStage ( int StageOffset, int StageTypeOffset )⚓︎

This function changes the current floor, and it's stage. For the changes to fully apply, either use the reseed console command, or Game.StartStageTransition.

StageOffset acts as the new "floor":

  • 1 would be equally difficult to Basement I,
  • 2 would be equally difficult to Basement II,
  • 3 would be equally difficult to Caves I

StageTypeOffset tells the game what "stage" to use, based on the listed IDs in stages.xml, however, the default stage of the floor's ID will be added on top of this

  • StageOffset = 1 uses the stage at ID: StageTypeOffset + 1(Basement's stage ID),
  • StageOffset = 2 uses the stage at ID: StageTypeOffset + 1(Same as StageOffset 1),
  • StageOffset = 3 uses the stage at ID: StageTypeOffset + 4(Caves' stage ID)

If you wish to directly use a stage ID, you can subtract the default stage for any given floor using a function like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
local function defaultStageOfFloor(StageOffset)
    if (StageOffset == 0) then
        print("Attempting to get default stage of floor 0. This is not recommended")
        Isaac.DebugString("Attempting to get default stage of floor 0. This is not recommended")
        return 0
    elseif (StageOffset <= 8) then
        return math.ceil(StageOffset/2) * 3 -2
    else
        return 10 + (StageOffset-8) * 2
    end
end

Notes

If you pass StageOffset = 0, the function acts (seemingly) arbitrarily, though it is still possible to use

StageOffset = -1 has an unusually small floor

StageOffsets 9, 12, and 13 are all seemingly hardcoded in some ways. Blue Womb seems to have it's backdrop and layout forced, while The Void and Home seems to force their name and backdrop


Set·State·Flag ()⚓︎

void SetStateFlag ( LevelStateFlag LevelStateFlag, boolean Val )⚓︎


Show·Map ()⚓︎

void ShowMap ( )⚓︎

Show's all map (world/sun card effect) except the top secret room.


Show·Name ()⚓︎

void ShowName ( boolean Sticky )⚓︎


Uncover·Hidden·Door ()⚓︎

void UncoverHiddenDoor ( int CurrentRoomIdx, DoorSlot Slot )⚓︎

Uncovers the door on both sides by modifying the saved grid entities for neighboring room.


Update ()⚓︎

void Update ( )⚓︎


Update·Visibility ()⚓︎

void UpdateVisibility ( )⚓︎

Notes

Whenever you update the visibility of a room on the minimap, it won't update the map automatically, since it is cached. You have to explicitly call UpdateVisibility() afterwards to apply any changes.

Example Code

This code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-- Local variables
local game = Game()
local level = game:GetLevel()

-- Give the player the Compass effect, which will display all of the floor's special rooms on the mini-map
level:ApplyCompassEffect()

-- Remove the icon for the Treasure Room specifically
local treasureIndex = level:QueryRoomTypeIndex(RoomType.ROOM_TREASURE, false, RNG())
local treasureRoom = level:GetRoomByIdx(treasureIndex)
treasureRoom.DisplayFlags = 0

-- Since the mini-map is cached, changing display flags won't update it unless we explicitly call this function
level:UpdateVisibility()


Variables⚓︎

Dungeon·Return·Position⚓︎

Vector DungeonReturnPosition⚓︎


Dungeon·Return·Room·Index⚓︎

int DungeonReturnRoomIndex⚓︎


Enter·Door⚓︎

int EnterDoor⚓︎

This value defines on which doorslot you entered the room.

Bugs

Changing this value has no impact on anything. the EnterDoor value is always determined by the LeaveDoor Value and the game itself.


Greed·Mode·Wave⚓︎

int GreedModeWave⚓︎


Leave·Door⚓︎

int LeaveDoor⚓︎

This value defines on which doorslot you are positioned after the transition. You will always end up at the oposite side of the door specified. Example: LeaveDoor=1 (Up0) will position you at Doorslot Down0 (Logic: Doorslot+2)

Notes

if level.LeaveDoor is set to anything other than -1, the function will transition based on the room you are currently in.



Last update: March 11, 2023