Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. local template = RegisterMod( "Animations Don't Stall room opening", 1 );
  2.  
  3. local roomClear = false
  4.  
  5. local Log = {"Log:"}
  6. function template:LogDraw()
  7. for i,j in ipairs(Log) do
  8. Isaac.RenderText(j,50,i*15,1,1,1,1)
  9. end
  10. end
  11.  
  12. local function print(str)
  13. table.insert(Log,tostring(str))
  14. if #Log > 10 then
  15. table.remove(Log,1)
  16. end
  17. end
  18.  
  19. -- Clears the current room, and spawns the appropriate rewards
  20. local function clearCurrentRoom()
  21.  
  22. -- Grabs the room
  23. local game = Game()
  24. local room = game:GetRoom()
  25.  
  26. -- Spawns the clear Awards
  27. room:SpawnClearAward ()
  28.  
  29. -- Check if it's a boss room
  30. if room:GetType() == RoomType.ROOM_BOSS then
  31. -- If so, try and spawn a DD
  32. room:TrySpawnDevilRoomDoor (true)
  33. end
  34.  
  35. -- Set the room clear to True for the minimap
  36. room:SetClear(true)
  37.  
  38. print ("Opening Doors")
  39. -- Opens the doors
  40. local door
  41. for i=1,8 do
  42. door = room:GetDoor(i)
  43. if door == nil then
  44. print ("Fuck You")
  45. else
  46. door:Open()
  47. door:SpawnDust()
  48. end
  49. end
  50.  
  51. -- Sets the DoOnce for the room
  52. roomClear = true
  53. end
  54.  
  55. function template:NpcUpdate(aNpc)
  56.  
  57. -- Might as well make this work for every enemy, it's reasonably cheap.
  58.  
  59. -- Make sure this is an enemy that counts.
  60. if aNpc.CanShutDoors then
  61.  
  62. -- If this enemy has died, and there are none left, clear the room.
  63. if aNpc:IsDead() then
  64. print (aNpc:GetAliveEnemyCount())
  65.  
  66.  
  67. if aNpc:GetAliveEnemyCount() <= 1 and roomClear == false then
  68. clearCurrentRoom()
  69. end
  70.  
  71.  
  72. else
  73. -- Prevent a room from clearing more than once
  74. roomClear = false
  75. end
  76. end
  77. end
  78.  
  79. function template:PostRender()
  80. template.LogDraw()
  81. end
  82.  
  83. template:AddCallback( ModCallbacks.MC_POST_RENDER, template.PostRender)
  84. template:AddCallback( ModCallbacks.MC_NPC_UPDATE, template.NpcUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement