Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("yourModName", 1)
- local game = Game()
- -- trinkets
- TrinketType.TRINKET_YOUR_TRINKET = Isaac.GetTrinketIdByName("Your Trinket") -- your trinketId
- -- costumes
- Mod.COSTUME_OF_YOUR_TRINKET = Isaac.GetCostumeIdByPath("gfx/characters/yourtrinketscostume.anm2") -- your costumeId
- function Mod:setModdedTrinketCostume(consol,para)
- if OnPickupSwitch(consol) then -- takes "onPickup" and checks if it's state is 'true'.
- -- If so, the it will return true. Otherwise it will return false
- for i = 0, (game:GetNumPlayers() - 1) do
- local player = Isaac.GetPlayer(i)
- local playerData = player:GetData()
- if playerData.YourTrinketName == true then
- 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
- playerData.YourTrinketName = false
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setModdedTrinketCostume)
- -- on post peffect update
- function Mod:onModUpdate(player)
- local playerData = player:GetData() -- if you already assigned a variable to player:GetData() that's fine. Just make sure to use it instead of playerData
- if game:GetFrameCount() == 1 then
- playerData.YourTrinketName = false -- saves and keeps track if the player has picked up YOUR trinket | ex. playerData.BloodyCobweb
- end
- if trinketCostumesMod then -- trinket costume mod is active
- if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) -- still have to check if the player has the trinket
- and playerData.YourTrinketName == false then
- -- add the costume
- ctc:AddTrinketCostume(player, TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_OF_YOUR_TRINKET)
- if hasTrinketCostume == true then -- global variable, got set to 'true' in the function above
- playerData.YourTrinketName = true -- the player now has the costume
- hasTrinketCostume = false -- reset hasTrinketCostume for a later use
- end
- end
- if (not player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET))
- and playerData.YourTrinketName == 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)
- playerData.YourTrinketName = false
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onModUpdate)
Add Comment
Please, Sign In to add comment