1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-15 21:24:49 +00:00
opus/sys/apis/sound.lua

18 lines
314 B
Lua
Raw Normal View History

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