Josh64

Donor Card

May 3rd, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. local Mod = RegisterMod("YourFolderName", 1)
  2. local game = Game()
  3.  
  4. local donorcard = {
  5. SPAWN_CHANCE = 50, -- chance to spawn a blood donation machine.
  6. MaggieStart = true -- should Maggie start with the Trinket?
  7. }
  8.  
  9. TrinketType.TRINKET_DONOR_CARD = Isaac.GetTrinketIdByName("Donor Card")
  10.  
  11. -- console commands
  12. function Mod:costumizeMaggie(consol,para)
  13. if consol == "betterMaggie" then
  14. if donorcard.MaggieStart == false then
  15. donorcard.MaggieStart = true
  16. Isaac.ConsoleOutput("Maggie will start with the Donor Card")
  17. else
  18. donorcard.MaggieStart = false
  19. Isaac.ConsoleOutput("Maggie won't start with the Donor Card")
  20. end
  21. end
  22. end
  23. SuperBum:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.costumizeMaggie)
  24.  
  25. -- on post peffect update
  26. function Mod:onInit(player)
  27.  
  28. -- stuff, which happens on frame 1
  29. if game:GetFrameCount() == 1 then
  30.  
  31. -- let Maggie start with the trinket
  32. if player:GetPlayerType() == PlayerType.PLAYER_MAGDALENA
  33. and donorcard.MaggieStart == true then
  34.  
  35. -- player gets the donor card trinket
  36. player:GetTrinket(TrinketType.TRINKET_DONOR_CARD)
  37. end
  38. end
  39. end
  40. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onInit)
  41.  
  42.  
  43. -- on new room
  44. function Mod:onNewRoom(_)
  45. local player = Isaac.GetPlayer(0)
  46. local roomType = game:GetRoom():GetType()
  47.  
  48. -- check if the player has the trinket
  49. if player:HasTrinket(TrinketType.TRINKET_DONOR_CARD)
  50. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_DONOR_CARD) then
  51.  
  52. -- check if the player already visited room and if the room is a shop
  53. if game:GetRoom():IsFirstVisit() == true
  54. and roomType == RoomType.ROOM_SHOP then
  55.  
  56. -- get RNG if needed
  57. local rng = player:GetTrinketRNG(TrinketType.TRINKET_DONOR_CARD)
  58. local roll = rng:RandomInt(100)
  59.  
  60. if roll < donorcard.SPAWN_CHANCE then
  61.  
  62. -- spawn the blood donation machine
  63. Isaac.Spawn(EntityType.ENTITY_SLOT, 8, 0, Vector(250, 250), Vector(0, 0), player) -- position needs adjustment
  64. end
  65. end
  66. end
  67. end
  68. Mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, Mod.onNewRoom)
Advertisement
Add Comment
Please, Sign In to add comment