Advertisement
alestane

Sound code

Feb 27th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. local sound = {}
  2. local soundChannel = {channel = audio.reserveChannels(audio.reservedChannels + 1)}
  3. local soundLocation = "audio/"
  4. local soundType = ".wav"
  5. local volume = 1
  6.  
  7. function sound:Play(audioArg)
  8.     local file = audio.loadSound(soundLocation .. audioArg .. soundType)
  9.     local play = audio.play(file, soundChannel)
  10.     audio.setVolume(volume, 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.setVolume(volume, soundChannel)
  18.         end
  19.     end
  20. end
  21.  
  22. Runtime:addEventListener("Options", sound)
  23. return sound
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement