mirror of
https://codeberg.org/SumianVoice/sum_airship.git
synced 2025-03-15 04:11:23 +00:00
slightly improved sound system
This commit is contained in:
parent
3d163aa37b
commit
9adbfaa517
1 changed files with 28 additions and 13 deletions
41
init.lua
41
init.lua
|
@ -178,6 +178,30 @@ local boat = {
|
|||
}
|
||||
}
|
||||
|
||||
local sounds = {
|
||||
engine_idle = {
|
||||
gain = 0.2,
|
||||
max_hear_distance = 10,
|
||||
loop = false,
|
||||
},
|
||||
engine_stop = {
|
||||
gain = 0.8,
|
||||
max_hear_distance = 10,
|
||||
loop = false,
|
||||
},
|
||||
engine_boost = {
|
||||
gain = 1,
|
||||
max_hear_distance = 10,
|
||||
loop = false,
|
||||
},
|
||||
}
|
||||
|
||||
function boat.sound_play(self, name, sound_params)
|
||||
local params = sound_params
|
||||
params.object = self.object
|
||||
return minetest.sound_play(name, params)
|
||||
end
|
||||
|
||||
function boat.update_sound(self, dtime)
|
||||
local fuel = self._fuel
|
||||
if not fuel or not type(fuel) == "number" then return false end
|
||||
|
@ -192,30 +216,21 @@ function boat.update_sound(self, dtime)
|
|||
if not self._sounds.engine.playing then
|
||||
self._sounds.engine.playing = true
|
||||
self._sounds.engine.time_elapsed = 0
|
||||
self._sounds.engine.handle = minetest.sound_play("sum_airship_lip_trill", {
|
||||
gain = 1,
|
||||
object = self.object,
|
||||
max_hear_distance = 10,
|
||||
loop = false,
|
||||
})
|
||||
self._sounds.engine.handle = boat.sound_play(self, "sum_airship_lip_trill", sounds.engine_boost)
|
||||
if self._sounds.engine_stop.playing then
|
||||
minetest.sound_stop(self._sounds.engine_stop.handle)
|
||||
self._sounds.engine_stop.playing = false
|
||||
self._sounds.engine_stop.time_elapsed = 0
|
||||
end
|
||||
end
|
||||
elseif self._sounds.engine.playing then
|
||||
elseif self._sounds.engine.playing
|
||||
and self._sounds.engine_stop.time_elapsed then
|
||||
minetest.sound_stop(self._sounds.engine.handle)
|
||||
self._sounds.engine.playing = false
|
||||
if not self._sounds.engine_stop.playing then
|
||||
self._sounds.engine_stop.playing = true
|
||||
self._sounds.engine_stop.time_elapsed = 0
|
||||
self._sounds.engine_stop.handle = minetest.sound_play("sum_airship_lip_trill_end", {
|
||||
gain = 0.8,
|
||||
object = self.object,
|
||||
max_hear_distance = 10,
|
||||
loop = false,
|
||||
})
|
||||
self._sounds.engine_stop.handle = boat.sound_play(self, "sum_airship_lip_trill_end", sounds.engine_stop)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue