TeamREPENTOGON / TeamREPENTOGON/REPENTOGON

Isaac.CreateTimer runs instantly in MC_POST_NEW_ROOM

Open
#462 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

borderline unnecessary bug
Dominant language
C++
Stars
345
Forks
51
Avg merge
11h 2m
Merged PRs (30d)
4

Description

If Isaac.CreateTimer is called in MC_POST_NEW_ROOM callback, it'll fire instantly upon entering the room even with high interval set. Whether the timer is set as persistent or not appears to have no obvious effect. If the function is set to run more than once, it'll fire with the correct delay after the first call.

Reproduction is as simple as running Isaac.CreateTimer in a function called by the MC_POST_NEW_ROOM callback.

local mod = RegisterMod("Test", 1)

local function PostNewRoom()
    Isaac.CreateTimer(function ()
        Isaac.Spawn(
            EntityType.ENTITY_PICKUP,
            PickupVariant.PICKUP_COLLECTIBLE,
            CollectibleType.COLLECTIBLE_SAD_ONION,
            Game():GetRoom():GetCenterPos(),
            Vector.Zero,
            nil
        )
    end, 60, 1, false)
end

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, PostNewRoom)

Marking as low priority since there's a "good enough" workaround for now of wrapping the CreateTimer in another CreateTimer with 0 or 1 frame of interval.

local function PostNewRoom()
    Isaac.CreateTimer(function ()
        Isaac.CreateTimer(function ()
            Isaac.Spawn(
                EntityType.ENTITY_PICKUP,
                PickupVariant.PICKUP_COLLECTIBLE,
                CollectibleType.COLLECTIBLE_SAD_ONION,
                Game():GetRoom():GetCenterPos(),
                Vector.Zero,
                nil
            )
        end, 30, 1, true)
    end, 0, 1, true)
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the MC_POST_NEW_ROOM reproduction with Isaac.CreateTimer and compare its behavior with timers created outside that callback. Trace the Isaac.CreateTimer and MC_POST_NEW_ROOM entry points to determine why a single-run timer fires immediately. Done means a timer created there respects its interval, including when persistent is false, while repeated timers retain their expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.