Josh64

Flooded Pits

Aug 17th, 2020 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. local Mod = RegisterMod("FloodedPits", 1);
  2. local game = Game()
  3.  
  4. function Mod:onPits()
  5.  
  6. local level = game:GetLevel()
  7. local room = level:GetCurrentRoom()
  8. local backdrop = room:GetBackdropType()
  9.  
  10. if CurRoom ~= level:GetCurrentRoomIndex() or CurStage ~= level:GetStage() then
  11. -- new room
  12. RoomConfig = {}
  13. for i = 1, room:GetGridSize() do
  14. local Grid = room:GetGridEntity(i)
  15. if Grid == nil then
  16. RoomConfig[i] = nil
  17. else
  18. RoomConfig[i] = {Type = Grid.Desc.Type, Variant = Grid.Desc.Variant, State = Grid.Desc.State}
  19.  
  20. end
  21. end
  22. end
  23. CurRoom = level:GetCurrentRoomIndex()
  24. CurStage = level:GetStage()
  25.  
  26. -- check for chances
  27. for i = 1, room:GetGridSize() do
  28. local Grid = room:GetGridEntity(i)
  29. if Grid then
  30. if Grid.Desc.Type == GridEntityType.GRID_PIT then
  31. -- your code
  32. if level:GetStageType() == StageType.STAGETYPE_AFTERBIRTH
  33. or backdrop == 6 then
  34. local sprite = Grid.Sprite
  35. sprite:ReplaceSpritesheet(0, "gfx/grid/custom/grid_pit_water_drownedcaves.png") -- place here your png file
  36. Grid.Sprite = sprite
  37. Isaac.ConsoleOutput("Water!!")
  38. end
  39. end
  40. end
  41. -- general code
  42. -- if Grid and RoomConfig[i] and
  43. -- (Grid.Desc.Type ~= RoomConfig[i].Type
  44. -- or Grid.Desc.Variant ~= RoomConfig[i].Variant
  45. -- or Grid.Desc.State ~= RoomConfig[i].State)
  46. -- then
  47. -- Isaac.ConsoleOutput("Ok")
  48. -- specific grid modifications
  49. -- if RoomConfig[i].Type == GridEntityType.GRID_PIT
  50. -- and RoomConfig[i].State == 1
  51. -- then
  52. -- your code
  53. -- end
  54. -- end
  55. if Grid then
  56. RoomConfig[i] = { Type=Grid.Desc.Type,
  57. Variant=Grid.Desc.Variant,
  58. State=Grid.Desc.State,
  59. }
  60. else
  61. RoomConfig[i] = nil
  62. end
  63. end
  64. end
  65. -- Mod:AddCallback(ModCallbacks.MC_POST_UPDATE, Mod.onPits)
  66. Mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, Mod.onPits)
Advertisement
Add Comment
Please, Sign In to add comment