Josh64

Updated Modded Trinket support 2

Jan 12th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. local Mod = RegisterMod("yourModName", 1)
  2. local game = Game()
  3.  
  4. -- trinkets
  5. TrinketType.TRINKET_YOUR_TRINKET = Isaac.GetTrinketIdByName("Your Trinket") -- your trinketId
  6. -- costumes
  7. Mod.COSTUME_OF_YOUR_TRINKET = Isaac.GetCostumeIdByPath("gfx/characters/yourtrinketscostume.anm2") -- your costumeId
  8.  
  9.  
  10. function Mod:setModdedTrinketCostume(consol,para)
  11. if OnPickupSwitch(consol) then -- takes "onPickup" and checks if it's state is 'true'.
  12. -- If so, the it will return true. Otherwise it will return false
  13. for i = 0, (game:GetNumPlayers() - 1) do
  14. local player = Isaac.GetPlayer(i)
  15. local playerData = player:GetData()
  16. if playerData.YourTrinketName == true then
  17. if ctc:GetHeldTrinkets(player, TrinketType.TRINKET_YOUR_TRINKET) then -- check if the player holds the trinket in one of the..
  18. -- trinket slots (returns true or false)
  19. player:TryRemoveNullCostume(Mod.COSTUME_OF_YOUR_TRINKET) -- remove costume
  20. playerData.YourTrinketName = false
  21. end
  22. end
  23. end
  24. end
  25. end
  26. Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setModdedTrinketCostume)
  27.  
  28. -- on post peffect update
  29. function Mod:onModUpdate(player)
  30.  
  31. 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
  32.  
  33. if game:GetFrameCount() == 1 then
  34. playerData.YourTrinketName = false -- saves and keeps track if the player has picked up YOUR trinket | ex. playerData.BloodyCobweb
  35. end
  36.  
  37.  
  38. if trinketCostumesMod then -- trinket costume mod is active
  39. if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) -- still have to check if the player has the trinket
  40. and playerData.YourTrinketName == false then
  41. -- add the costume
  42. if onPickup == false then -- global variable which decides when the costume gets applied
  43. if ctc:TrinketIsSmelted(player, TrinketType.TRINKET_YOUR_TRINKET) then -- specific function which checks if the to evaluated trinket is smelted
  44. -- returns 'true' or 'false'
  45. -- costume would get applied by smelting the trinket
  46. player:AddNullCostume(Mod.COSTUME_OF_YOUR_TRINKET)
  47.  
  48. -- set moddedCos. to true
  49. playerData.YourTrinketName = true
  50. end
  51. else
  52. if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) then
  53. -- costume would get applied by picking up the trinket
  54. player:AddNullCostume(Mod.COSTUME_OF_YOUR_TRINKET)
  55.  
  56. -- set moddedCos. to true
  57. playerData.YourTrinketName = true
  58. end
  59. end
  60. end
  61. if (not player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET))
  62. and playerData.YourTrinketName == true then -- check if the costume needs to be removed
  63. -- remove the costume
  64. ctc:RemoveTrinketCostume(player, TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_OF_YOUR_TRINKET)
  65. playerData.YourTrinketName = false
  66. end
  67. end
  68. end
  69. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onModUpdate)
Add Comment
Please, Sign In to add comment