Advertisement
lavalevel

Music Module

Aug 9th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local options = require "optionsData"
  2.  
  3. local music = {}
  4. local musicChannel = 1
  5. local volume = options.Music.Volume
  6.  
  7. function music:Play(file)
  8.     local file = audio.loadStream("snd/" .. file .. ".mp3")
  9.     audio.setVolume(volume, {channel = musicChannel})
  10.     local play = audio.play(file, {channel = musicChannel, fadein = 500, loops = -1})
  11. end
  12.  
  13. function music:Options(event)
  14.     if event.Music then
  15.         if event.Music.Volume then
  16.             volume = event.Music.Volume
  17.             audio.pause(musicChannel)
  18.             audio.setVolume(volume, {channel = musicChannel})
  19.             audio.resume(musicChannel)
  20.         end
  21.     end
  22. end
  23.  
  24. Runtime:addEventListener("Options", music)
  25. return music
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement