Advertisement
lavalevel

Sound Module

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