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
- 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
- playerData.YourTrinketName = 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
- playerData.YourTrinketName = true
- end
- 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
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onModUpdate)
Add Comment
Please, Sign In to add comment