Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("FloodedPits", 1);
- local game = Game()
- function Mod:onPits()
- local level = game:GetLevel()
- local room = level:GetCurrentRoom()
- local backdrop = room:GetBackdropType()
- if CurRoom ~= level:GetCurrentRoomIndex() or CurStage ~= level:GetStage() then
- -- new room
- RoomConfig = {}
- for i = 1, room:GetGridSize() do
- local Grid = room:GetGridEntity(i)
- if Grid == nil then
- RoomConfig[i] = nil
- else
- RoomConfig[i] = {Type = Grid.Desc.Type, Variant = Grid.Desc.Variant, State = Grid.Desc.State}
- end
- end
- end
- CurRoom = level:GetCurrentRoomIndex()
- CurStage = level:GetStage()
- -- check for chances
- for i = 1, room:GetGridSize() do
- local Grid = room:GetGridEntity(i)
- if Grid then
- if Grid.Desc.Type == GridEntityType.GRID_PIT then
- -- your code
- if level:GetStageType() == StageType.STAGETYPE_AFTERBIRTH
- or backdrop == 6 then
- local sprite = Grid.Sprite
- sprite:ReplaceSpritesheet(0, "gfx/grid/custom/grid_pit_water_drownedcaves.png") -- place here your png file
- Grid.Sprite = sprite
- Isaac.ConsoleOutput("Water!!")
- end
- end
- end
- -- general code
- -- if Grid and RoomConfig[i] and
- -- (Grid.Desc.Type ~= RoomConfig[i].Type
- -- or Grid.Desc.Variant ~= RoomConfig[i].Variant
- -- or Grid.Desc.State ~= RoomConfig[i].State)
- -- then
- -- Isaac.ConsoleOutput("Ok")
- -- specific grid modifications
- -- if RoomConfig[i].Type == GridEntityType.GRID_PIT
- -- and RoomConfig[i].State == 1
- -- then
- -- your code
- -- end
- -- end
- if Grid then
- RoomConfig[i] = { Type=Grid.Desc.Type,
- Variant=Grid.Desc.Variant,
- State=Grid.Desc.State,
- }
- else
- RoomConfig[i] = nil
- end
- end
- end
- -- Mod:AddCallback(ModCallbacks.MC_POST_UPDATE, Mod.onPits)
- Mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, Mod.onPits)
Advertisement
Add Comment
Please, Sign In to add comment