Zamiel icon

WR Seed Getter

Zamiel | PRO | 10/29/18 02:23:50 PM UTC | 0 ⭐ | 394 👁️ | Never ⏰ | []
Lua |

2.05 KB

|

None

|

0 👍

/

0 👎

-- WR Seed Getter
-- by Zamiel
 
-- This mod will look through seeds for certain conditions.
local WRSeedGetter = RegisterMod("WR-Seed-Getter", 1)
 
-- Global variables
WRSeedGetter.restart = false
WRSeedGetter.attempts = 0
WRSeedGetter.seeds = {
  "B9Q9 NWJY",
}
 
-- ModCallbacks.MC_POST_RENDER (2)
function WRSeedGetter:PostRender()
  if WRSeedGetter.restart and
     WRSeedGetter.attempts < #WRSeedGetter.seeds then
 
    WRSeedGetter.restart = false
    WRSeedGetter.attempts = WRSeedGetter.attempts + 1
 
    local seed = WRSeedGetter.seeds[WRSeedGetter.attempts]
    Isaac.DebugString("On attempt: " .. WRSeedGetter.attempts)
    Isaac.ExecuteCommand("seed " .. seed)
    return
  end
end
 
-- ModCallbacks.MC_POST_GAME_STARTED (15)
function WRSeedGetter:PostGameStarted(saveState)
  if WRSeedGetter:Check() then
    local game = Game()
    local seeds = game:GetSeeds()
    local seed = seeds:GetStartSeedString()
    Isaac.DebugString("Found good seed: " .. seed)
  end
 
  -- Doing a "restart" here does not work for some reason, so mark to do it on the next frame
  WRSeedGetter.restart = true
 
  -- On Booster Pack 3 and below, the recharge sound will play at the beginning of a run
  local sfx = SFXManager()
  sfx:Stop(SoundEffect.SOUND_BATTERYCHARGE) -- 170
end
 
function WRSeedGetter:Check()
  -- We need better than 4.0 damage
  local game = Game()
  local player = game:GetPlayer(0)
  if player.Damage <= 4.25 then
    return false
  end
 
  -- We need a Sacrifice Room below
  local room = game:GetRoom()
  local door = room:GetDoor(3) -- The bottom door
  if door ~= nil and
     door.TargetRoomType == RoomType.ROOM_SACRIFICE then -- 13
 
    return true
  end
 
  return false
end
 
WRSeedGetter:AddCallback(ModCallbacks.MC_POST_RENDER, WRSeedGetter.PostRender) -- 2
WRSeedGetter:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, WRSeedGetter.PostGameStarted) -- 15
 
Isaac.DebugString("+-----------------------------+")
Isaac.DebugString("| WR Seed Getter initialized. |")
Isaac.DebugString("+-----------------------------+")

Comments