1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-24 06:03:26 +00:00
opus/sys/apis/sound.lua
kepler155c@gmail.com 0e3fb88f1d set sound volume
2018-12-04 01:33:58 -05:00

19 lines
337 B
Lua

local peripheral = _G.peripheral
local Sound = {
_volume = 1,
}
function Sound.play(sound, vol)
local speaker = peripheral.find('speaker')
if speaker then
speaker.playSound('minecraft:' .. sound, vol or Sound._volume)
end
end
function Sound.setVolume(volume)
Sound._volume = math.max(0, math.min(volume, 1))
end
return Sound