mirror of
https://github.com/kepler155c/opus
synced 2024-12-26 00:20:26 +00:00
set sound volume
This commit is contained in:
parent
c9a42e2502
commit
0e3fb88f1d
@ -1,12 +1,18 @@
|
||||
local peripheral = _G.peripheral
|
||||
|
||||
local Sound = { }
|
||||
local Sound = {
|
||||
_volume = 1,
|
||||
}
|
||||
|
||||
function Sound.play(sound, vol)
|
||||
local speaker = peripheral.find('speaker')
|
||||
if speaker then
|
||||
speaker.playSound('minecraft:' .. sound, vol or 1)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user