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
- }
- -- 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
- if onPickup == true then -- check if the player holds trinkets since their costumes need to be removed
- for m = 0, (game:GetNumPlayers() - 1) do
- local player = Isaac.GetPlayer(m)
- local playerData = player:GetData()
- if ctc:GetHeldTrinkets (player, TrinketType.TRINKET_YOUR_TRINKET) then -- check if the player holds the trinket in one of the..
- -- trinket slots (returns true or false)
- player:TryRemoveNullCostume(Mod.COSTUME_OF_YOUR_TRINKET) -- remove costume
- moddedCos.YourTrinket = false
- end
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setTrinketCostume)
- function Mod:onNewRun(bool)
- -- reset 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
- if onPickup == false then -- global variable which decides when the costume gets applied
- if ctc:TrinketIsSmelted(player, TrinketType.TRINKET_YOUR_TRINKET) then -- specific function which checks if the to evaluated trinket is smelted
- -- returns 'true' or 'false'
- -- costume would get applied by smelting the trinket
- player:AddNullCostume(Mod.COSTUME_OF_YOUR_TRINKET)
- -- set moddedCos. to true
- moddedCos.YourTrinket = true
- end
- else
- if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) then
- -- costume would get applied by picking up the trinket
- player:AddNullCostume(Mod.COSTUME_OF_YOUR_TRINKET)
- -- set moddedCos. to true
- moddedCos.YourTrinket = true
- end
- 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
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_UPDATE, Mod.onModdedCostumeUpdate)
Add Comment
Please, Sign In to add comment