Zamiel

WR Seed Getter

Oct 29th, 2018
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. -- WR Seed Getter
  2. -- by Zamiel
  3.  
  4. -- This mod will look through seeds for certain conditions.
  5. local WRSeedGetter = RegisterMod("WR-Seed-Getter", 1)
  6.  
  7. -- Global variables
  8. WRSeedGetter.restart = false
  9. WRSeedGetter.attempts = 0
  10. WRSeedGetter.seeds = {
  11.   "B9Q9 NWJY",
  12. }
  13.  
  14. -- ModCallbacks.MC_POST_RENDER (2)
  15. function WRSeedGetter:PostRender()
  16.   if WRSeedGetter.restart and
  17.      WRSeedGetter.attempts < #WRSeedGetter.seeds then
  18.  
  19.     WRSeedGetter.restart = false
  20.     WRSeedGetter.attempts = WRSeedGetter.attempts + 1
  21.  
  22.     local seed = WRSeedGetter.seeds[WRSeedGetter.attempts]
  23.     Isaac.DebugString("On attempt: " .. WRSeedGetter.attempts)
  24.     Isaac.ExecuteCommand("seed " .. seed)
  25.     return
  26.   end
  27. end
  28.  
  29. -- ModCallbacks.MC_POST_GAME_STARTED (15)
  30. function WRSeedGetter:PostGameStarted(saveState)
  31.   if WRSeedGetter:Check() then
  32.     local game = Game()
  33.     local seeds = game:GetSeeds()
  34.     local seed = seeds:GetStartSeedString()
  35.     Isaac.DebugString("Found good seed: " .. seed)
  36.   end
  37.  
  38.   -- Doing a "restart" here does not work for some reason, so mark to do it on the next frame
  39.   WRSeedGetter.restart = true
  40.  
  41.   -- On Booster Pack 3 and below, the recharge sound will play at the beginning of a run
  42.   local sfx = SFXManager()
  43.   sfx:Stop(SoundEffect.SOUND_BATTERYCHARGE) -- 170
  44. end
  45.  
  46. function WRSeedGetter:Check()
  47.   -- We need better than 4.0 damage
  48.   local game = Game()
  49.   local player = game:GetPlayer(0)
  50.   if player.Damage <= 4.25 then
  51.     return false
  52.   end
  53.  
  54.   -- We need a Sacrifice Room below
  55.   local room = game:GetRoom()
  56.   local door = room:GetDoor(3) -- The bottom door
  57.   if door ~= nil and
  58.      door.TargetRoomType == RoomType.ROOM_SACRIFICE then -- 13
  59.  
  60.     return true
  61.   end
  62.  
  63.   return false
  64. end
  65.  
  66. WRSeedGetter:AddCallback(ModCallbacks.MC_POST_RENDER, WRSeedGetter.PostRender) -- 2
  67. WRSeedGetter:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, WRSeedGetter.PostGameStarted) -- 15
  68.  
  69. Isaac.DebugString("+-----------------------------+")
  70. Isaac.DebugString("| WR Seed Getter initialized. |")
  71. Isaac.DebugString("+-----------------------------+")
Advertisement
Add Comment
Please, Sign In to add comment