Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("yourModName", 1)
- local game = Game()
- local moddedCos = { -- keeps track which trinket is in the player posession
- YourTrinket = false -- ex. BloodyCobweb = false
- }
- -- trinkets
- TrinketType.TRINKET_YOUR_TRINKET = Isaac.GetTrinketIdByName("Your Trinket")
- -- costumes
- Mod.COSTUME_OF_YOUR_TRINKET = Isaac.GetCostumeIdByPath("gfx/characters/yourtrinketscostume.anm2")
- -- change if the costume gets applied on pickup or by smelting
- function Mod:setTrinketCostume(consol,para)
- if consol == "onPickup" then -- global. regulates when a trinket costume is applied
- if moddedCos.YourTrinket == true then
- ctc:SwitchCostumeRequirement(TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_OF_YOUR_TRINKET) -- gets called if the costume gets applied by picking up the trinket. Also removes the costume until it's applied again.
- if switchTrinketBoolean == true then -- got set to 'true' in the function above
- moddedCos.YourTrinket = false -- reset moddedCos so that the costume can be reevaluated/applied again
- switchTrinketBoolean = false -- reset switchTrinketBoolean for a later use
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setTrinketCostume)
- function Mod:onNewRun(bool)
- -- reset all moddedCos. variables to false at the begin of a new run
- if bool == false -- is false on the start of a complete new game
- and trinketCostumesMod then
- moddedCos.YourTrinket = false
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, Mod.onNewRun)
- function Mod:onModdedCostumeUpdate(_)
- -- check if trinket costume mod is active
- if trinketCostumesMod then
- for i = 0, (game:GetNumPlayers() - 1) do
- local player = Isaac.GetPlayer(i)
- if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) -- still have to check if the player has the trinket
- and moddedCos.YourTrinket == false then
- -- add the costume
- ctc:AddTrinketCostume(player, TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_OF_YOUR_TRINKET) -- applies the costumes. On smelting or pickup dependin on 'onPickup'
- -- change the moddedCos. boolean
- if switchTrinketBoolean == true then -- got set to 'true' in the function above
- moddedCos.YourTrinket = true -- the player now has the costume
- switchTrinketBoolean = false -- reset switchTrinketBoolean for a later use
- end
- end
- if (not player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET))
- and moddedCos.YourTrinket == true then -- check if the costume needs to be removed
- -- remove the costume
- ctc:RemoveTrinketCostume(player, TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_OF_YOUR_TRINKET)
- moddedCos.YourTrinket = false -- needs to be reset so that the costume could be...
- -- applied again in the same run
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_UPDATE, Mod.onModdedCostumeUpdate)
Advertisement
Add Comment
Please, Sign In to add comment