Skip to content
Guantol-Lemat edited this page Nov 16, 2023 · 3 revisions

Enable Debug Mode

In order to enable "debug mode" for ReactionAPI one must first go into the main.lua and remove the comment statement (--) on the line: include("reactionAPI_scripts.tools.debug"), then close and reopen the game.

Once enabled you should be seeing these text strings being rendered on screen:

Debug

If not seen, check for errors by opening the debug console or inspecting the log.txt file, if the size of the window is big enough to display the entirety of the text, or if you forgot to save the main.lua file prior to reopening the game (speaking from experience here).

Diagnosing Problems

If you are debugging ReactionAPI due to a problem emerged from another mod, the first thing to do is to check whether or not the API properly detects the various items in the room, in order to determine which of the two is the source of the problem.

Every Update Cycle the mod updates three main objects: CollectibleData (comprised by collectiblesInRoom, newCollectibles, blindPedestals and shopItems), cQualityStatus and cBestQuality

These variables are all strictly connected: specifically cQualityStatus depends off of CollectibleData, and cBestQuality is based off of cQualityStatus.

As such the main suspect of any miscalculation is CollectibleData.

Simple Diagnosis

For a Quick and Simple Diagnosis to check if the mod main variables are not being properly update, you can attempt to simulate the original situation that caused the problem to emerge, or even better if you still have a saved game with the problematic situation still present.

Keybinds

As a way to speed up the process of simulating the original situation you can use certain keybinds to execute specific commands

  • F3: Spawn a random Collectible
  • F4: Spawn the Sad Onion Collectible (Useful for testing on a specific Collectible)
  • F5: Get 999 coins (Useful for testing Shop Items)
  • F6: Reroll/Restock Item Pedestals/Shop Items
  • F7: Toggle Curse of the Blind

ℹ️ INFO: You can change the Collectible Spawned by F4 by editing the reactionAPI_scripts/tools/debug.lua file, specifically by changing the function:

cSpawn = function ()
        Isaac.DebugString("Pickup Spawned")
        Isaac.ExecuteCommand('spawn 5.100.#Your_Collectible_ID_Here')
end

and replacing #Your_Collectible_ID_Here with the ID of the collectible you want, see this page of the Isaac Wiki for a list of Collectibles and their relative ID.

Other useful Debug Commands

If the keybind functions are not sufficient, you can directly utilize the debug console.

Here are some useful/common Debug Commands used during testing:

spawn 5.100.#CollectibleID --Spawn a specific Collectible
debug 8 --Infinite Item Charges
giveitem c#CollectibleID -- Give yourself a specific Item
giveitem k10 -- Give yourself The Hermit (the Card that warps you to the Shop)
giveitem k18 -- Give yourself The Stars (the Card that warps you to the Treasure Room)
giveitem k19 -- Give yourself The Moon (the Card that warps you to the Secret Room)
giveitem k31 -- Give yourself The Joker (the Card that warps you to Devil/Angel Rooms)
giveitem k74 -- Give yourself The Moon? (the Cart that warps you to the Ultra Secret Room)

Reading Rendered Values

Once the situation has been replicated, you should see the rendered variables being updated from what they originally were

The most important out of the 5 are: CollectiblePresence, BlindCollectiblePresence as the others are dependent on these two:

Both of them are bit flags, or in simpler terms, a collection of true or false statements represented as sequential numbers (0 for false and 1 for true).

Each statement represents whether or not a specific "Quality" can be found in the current room (regardless of how many Items of that quality are actually present in the room).

QualityStatus

Here are some examples:

0x100010: In the current room there is at least one GLITCHED item, and at least one QUALITY_3 item
0x011001: In the current room there is at least one QUALITY_0 item, at least one QUALITY_1 item, and at least one QUALITY_4 item

The difference between CollectiblePresence, and BlindCollectiblePresence is that the former checks for Visible Collectibles only, whilst the latter checks for Blind Collectibles Only.

If these variables accurately reflect the events in the room, it's unlikely that the mod is broken. However that cannot be said for certain.

If you wish to proceed further with debugging you are going to need to do more thorough Analysis.

Thorough Debugging

Debugging CollectibleData

In order to be able to see the current values of CollectibleData, you can either:

  • Spawn a new Collectible
  • Press the 'O' key in your keyboard

This will print the entirety of CollectibleData inside of the log.txt file like this:

[INFO] - Lua Debug: Presence List:
#collectiblesInRoom_Entries_Here
[INFO] - Lua Debug: New Collectibles:
#newCollectibles_Entries_Here
[INFO] - Lua Debug: Blind Pedestals:
#blindPedestals_Entries_Here
[INFO] - Lua Debug: Shop Items:
#shopItems_Entries_Here

collectiblesInRoom

collectiblesInRoom contains all the items present in the current room.
An Entry is formatted like this:

[INFO] - Lua Debug: PickupID: #int, CollectibleID: #int, IsBlind:#bool, Cycle Order: #int, CollectibleName: #string

@PickupID: A number that uniquely identifies all the pedestals in the room, if a pedestal is Cycling (Glitched Crown/T.Isaac Effect) then you should see multiple entries with the same PickupID and different CycleOrder.
@CollectibleID: A number that defines what Collectible is on the pedestal.
@IsBlind: Whether or not the current collectible is Blind.
@Cycle Order: If the pedestal is Cycling this variable tells you the order in which the various items are switching.
@CollectibleName: A string containing the name of the collectible.

If you see that:

  • A Collectible is missing from the list.
  • A Collectible that's not in the room anymore, is still present within the list.
  • The Collectible data is incorrect (mainly IsBlind and CycleOrder).

Then the API is bugged and you should report it.

⚠️NOTE: This could also be caused by a mod incompatibility, so take note if this only occurs when a specific modded item is in your possession or has been activated.

ℹ️ INFO: The API ignores items that have been exchanged, which occurs when switching active items, or when replacing items in T.Isaac's inventory, so if they are missing from the list this is intentional behaviour.

newCollectibles

newCollectibles contains all the newly seen items, they persist only for a split second and then get wiped.
An Entry is formatted like this:

[INFO] - Lua Debug: CollectibleID: #int, IsBlind: #bool, CollectibleName: #string

@CollectibleID: A number that defines what Collectible is on the pedestal.
@IsBlind: Whether or not the current collectible is Blind.
@CollectibleName: A string containing the name of the collectible.

If you see that a collectible present in collectiblesInRoom has never appeared in any of the previous NewCollectibles: prints then the API is bugged and you should report it.

blindPedestals

blindPedestals contain a list of all PickupIDs tied to blind Pedestals.
An Entry is formatted like this:

[INFO] - Lua Debug: PickupID: #int

@PickupID: A number that uniquely identifies a pedestal that is affected by the Blind Curse.

If you see that a Blind Pedestal is present in collectiblesInRoom, but not in this list then the API is bugged and you should report it.

⚠️NOTE: This could also be caused by a mod incompatibility, specifically if a mod changes the behaviour of blind items, or introduces a "Blind" Curse of their own and has not added the proper Blind Conditions to ReactionAPI, in which case it's the mod that is causing the problem.

shopItems

shopItems contain a list of all PickupIDs tied to shop Items.
An Entry is formatted like this:

[INFO] - Lua Debug: PickupID: #int

@PickupID: A number that uniquely identifies a pedestal that is currently being sold for a price (this includes any of T.Keeper's Items, and Devil Deals).

If you see that an Item that's being sold is present in collectiblesInRoom, but not in this list then the API is bugged and you should report it.

How to Fix Common Problems

Collectibles Not Showing up in collectiblesInRoom

This cannot be fixed on your end as it is a detection problem of the API.

Collectibles Persisting inside of collectiblesInRoom, despite no longer being present

This can be due to the API not noticing that a collectible has been deleted.
For reference the API naturally detects that data should be deleted if:

  • An EntityEffect.POOF1 is Initialized in the same position as a Pedestal (All the Pedestal data is deleted), This most commonly occurs when Rerolling.
  • A Pedestal is collected (All the Pedestal data is deleted).
  • A Pedestal tied to an OptionGroup is collected (The data of all Pedestals with that same OptionGroup is deleted).
  • A shopItem no longer exists (All the data of that Pedestal is deleted), this is due to the fact that upon purchase the Entity is deleted an as such there will never be a MC_POST_UPDATE where collection can be detected.

If your mod deletes/rerolls collectibles in the room and the implemented detection system is not capable of handling that situation then you can Request a Reset.

Here is an example:

local RerolledPedestals = {}

local function UndetectedReroll(EntityPickup)
    --[[your custom code]]
    table.insert(RerolledPedestals, EntityPickup.Index)
end

local function RerollOnItemUse()
    for _, entity in ipairs(Isaac.FindByType(5, 100)) do
        if --[[your custom code]] then
            UndetectedReroll(entity)
        end
    end
    ReactionAPI.Interface.RequestReset(false, RerolledPedestals)
end

You can get more information on how RequestReset works by checking the doc.md

Collectibles are not treated as Blind

The API treats Collectibles as Blind only if the current curse is "Curse of The Blind" or if the collectible sprite matches that of the Question Mark:

questionmark

ℹ️ INFO: If a mod edits the resources\gfx\items\collectibles\questionmark.png directly then that is the sprite that will be matched.

If neither of these conditions are satisfied then the collectible is treated as Visible.

If you made any changes to how Blind collectibles work that goes against these conditions, or if you added a new type of "Blind" Curse, then you can Add a Blind Condition.

Here is an Example:

local curseOfTheBlight = Isaac.GetCurseIdByName("Curse of Blight")
local BLIGHT_FLAG = 1 << (curseOfTheBlight - 1)

local function IsCurseOfBlight()
    return Game():GetLevel():GetCurses() & BLIGHT_FLAG ~= 0
end

ReactionAPI.Interface.AddBlindCondition(IsCurseOfBlight, true)

You can get more information on how AddBlindCondition or other Blind related functions work by checking the doc.md

Collectibles are not treated as ShopItems

This cannot be fixed on your end as it is a detection problem of the API.