move apis into rom/modules/main for shell compatibility
This commit is contained in:
17
sys/modules/opus/sound.lua
Normal file
17
sys/modules/opus/sound.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local peripheral = _G.peripheral
|
||||
|
||||
local Sound = {
|
||||
_volume = 1,
|
||||
}
|
||||
|
||||
function Sound.play(sound, vol)
|
||||
peripheral.find('speaker', function(_, s)
|
||||
s.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
|
||||
Reference in New Issue
Block a user