Advertisement
Guest User

bonus.lua

a guest
Apr 20th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. ---------------------------------------------------
  2. -- BONUS SCRIPT                                  --
  3. -- by Natsu                                      --
  4. -- v0.1.0                                        --
  5. ---------------------------------------------------
  6.  
  7. local bonus = {}
  8.  
  9. ----------------------------------------------------------------------------
  10. --                               VARIABLES                                --
  11. ----------------------------------------------------------------------------
  12. local sectionNumber = 0 --Section where the bonus is located
  13. local doHandling = false --Controls whether the bonus controls apply or not
  14.  
  15. ----------------------------------------------------------------------------
  16. --                        API-related Sound Effects                       --
  17. ----------------------------------------------------------------------------
  18. local bonusDeathSFX = Audio.SfxOpen(Misc.resolveFile("bonusLose.ogg")) --Loads bonusLose SFX
  19. local bonusWinSFX = Audio.SfxOpen(Misc.resolveFile("bonusWin.ogg")) --Loads bonusWin SFX
  20.  
  21.  
  22. ----------------------------------------------------------------------------
  23.  
  24. function bonus.onInitAPI()
  25.     registerEvent(bonus, "onLoadSection", "sectionLoad")
  26.     registerEvent(bonus, "onTick", "handling")
  27.     registerEvent(bonus, "onNPCKill", "itemGet")
  28. end
  29.  
  30. --This function takes the parameters sent from the luna.lua file
  31. function bonus.parameters(bonusSection)
  32.     sectionNumber = bonusSection
  33. end
  34.  
  35. --This function replaces the death SFX if the player is in the bonus section and switches
  36. --doHandling to true
  37. function bonus.sectionLoad()
  38.     if player.section == sectionNumber then
  39.         Audio.sounds[8].sfx = bonusDeathSFX
  40.         doHandling = true
  41.     end
  42. end
  43.  
  44. --This function prevents player death and pauses the game
  45. function bonus.handling()
  46.     if player:mem(0x13E, FIELD_WORD) > 0 and doHandling then
  47.         player:mem(0x13E, FIELD_WORD, 0)
  48.         Misc.pause()
  49.         Animation.spawn(75, player.x, player.y)
  50.     end
  51. end
  52.  
  53. --This function plays the bonus win fanfare
  54. function bonus.itemGet(eventObj, npcID, killReason)
  55.     if npcID.id == 178 then
  56.         Audio.MusicStop()
  57.         SFX.play("bonusWinSFX")
  58.     end
  59. end
  60.  
  61. return bonus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement