1
0
mirror of https://github.com/kepler155c/opus synced 2025-02-07 12:40:01 +00:00
opus/sys/apis/sound.lua

18 lines
314 B
Lua
Raw Normal View History

2018-11-26 20:53:28 -05:00
local peripheral = _G.peripheral
2018-12-04 01:33:58 -05:00
local Sound = {
_volume = 1,
}
2018-11-26 20:53:28 -05:00
function Sound.play(sound, vol)
2019-01-02 23:56:01 -05:00
peripheral.find('speaker', function(_, s)
s.playSound('minecraft:' .. sound, vol or Sound._volume)
end)
2018-11-26 20:53:28 -05:00
end
2018-12-04 01:33:58 -05:00
function Sound.setVolume(volume)
Sound._volume = math.max(0, math.min(volume, 1))
end
2018-11-26 20:53:28 -05:00
return Sound