Josh64

sigh

Jan 12th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. -- function used to setup all the necessary trinket data. Gets called in the MC_POST_PEFFECT_UPDATE
  2. function ctc:RegisterTrinketCostume(trinketId, costumeId)
  3. for i = 0, (game:GetNumPlayers() - 1) do
  4.  
  5. local player = Isaac.GetPlayer(i)
  6. local playerData = player:GetData()
  7. playerData.TrinketCostume_trinket = {}
  8.  
  9. -- register the trinket data in the player data
  10. playerData.TrinketCostume_trinket[trinketId] = {
  11. HasTrinket = false,
  12. COSTUME = costumeId
  13. }
  14.  
  15. print(trinketId)
  16.  
  17. -- register the trinketId in a table for later use
  18. table.insert(moddedTrinkets, trinketId)
  19. Isaac.ConsoleOutput("Argh")
  20. end
  21. end
  22.  
  23. -- function used in the MC_EXECUTE_CMD callback of mods which want the compatibility
  24.  
  25. function ctc:SwitchCostumeRequirement(player, trinketId) -- outdated, but left in just in case with problems with the playerData version
  26.  
  27. local playerData = player:GetData()
  28.  
  29. if playerData.TrinketCostume_trinket[trinketId].HasTrinket == true then
  30. if player:GetTrinket(0) ~= nil then -- the player holds at least something
  31. if player:GetTrinket(0) == trinketId
  32. or player:GetTrinket(1) == trinketId then
  33. player:TryRemoveNullCostume(playerData.TrinketCostume_trinket[trinketId].COSTUME) -- remove costume
  34.  
  35. playerData.TrinketCostume_trinket[trinketId].HasTrinket = false
  36. end
  37. end
  38. end
  39. end
  40.  
  41. -- functions used in the MC_POST_UPDATE callback of mods which want the compatibility
  42.  
  43. function ctc:UpdateTrinketCostume(player, trinketId)
  44.  
  45. local playerData = player:GetData()
  46.  
  47. if player:HasTrinket(trinketId)
  48. and playerData.TrinketCostume_trinket[trinketId].HasTrinket == false then
  49.  
  50. print(trinketId)
  51. if onPickup == false then -- costume would get applied by smelting the trinket
  52. if player:GetTrinket(0) ~= trinketId
  53. and player:GetTrinket(1) ~= trinketId
  54. and applyCostume == true then -- still follows the same rules as base game trinkets
  55.  
  56. -- costume would get applied by smelting the trinket
  57. player:AddNullCostume(playerData.TrinketCostume_trinket[trinketId].COSTUME)
  58.  
  59. playerData.TrinketCostume_trinket[trinketId].HasTrinket = true
  60. end
  61. else
  62. if player:HasTrinket(trinketId) then
  63. -- costume would get applied by picking up the trinket
  64. player:AddNullCostume(playerData.TrinketCostume_trinket[trinketId].COSTUME)
  65.  
  66. playerData.TrinketCostume_trinket[trinketId].HasTrinket = true
  67. end
  68. end
  69.  
  70. elseif (not player:HasTrinket(trinketId))
  71. and playerData.TrinketCostume_trinket[trinketId].HasTrinket == true then
  72.  
  73. -- costume would get applied by picking up the trinket
  74. player:TryRemoveNullCostume(playerData.TrinketCostume_trinket[trinketId].COSTUME)
  75.  
  76. playerData.TrinketCostume_trinket[trinketId].HasTrinket = false
  77. end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment