mirror of
https://codeberg.org/SumianVoice/sum_airship.git
synced 2025-03-15 12:21:23 +00:00
sound for adding fuel
This commit is contained in:
parent
0ea50877a7
commit
b108328085
3 changed files with 61 additions and 37 deletions
|
@ -16,13 +16,14 @@ minetest.register_craftitem("sum_airship:hull", {
|
||||||
groups = { craftitem = 1 },
|
groups = { craftitem = 1 },
|
||||||
})
|
})
|
||||||
if true then
|
if true then
|
||||||
local w = "default:paper"
|
local w = "group:wool"
|
||||||
local b = "group:wood"
|
if not minetest.get_modpath("farming") then w = "default:paper" end
|
||||||
|
local b = "default:boat"
|
||||||
local m = "default:steel_ingot"
|
local m = "default:steel_ingot"
|
||||||
if minetest.get_modpath("mcl_boats")
|
if minetest.get_modpath("mcl_boats")
|
||||||
and minetest.get_modpath("mcl_wool")
|
and minetest.get_modpath("mcl_wool")
|
||||||
and minetest.get_modpath("mcl_core") then
|
and minetest.get_modpath("mcl_core") then
|
||||||
w = "mcl_wool:white"
|
w = "group:wool"
|
||||||
b = "mcl_boats:boat"
|
b = "mcl_boats:boat"
|
||||||
m = "mcl_core:iron_ingot"
|
m = "mcl_core:iron_ingot"
|
||||||
end
|
end
|
||||||
|
|
91
init.lua
91
init.lua
|
@ -180,57 +180,73 @@ local boat = {
|
||||||
|
|
||||||
local sounds = {
|
local sounds = {
|
||||||
engine_idle = {
|
engine_idle = {
|
||||||
gain = 0.2,
|
sound_name = "sum_airship_lip_trill",
|
||||||
|
gain = 1.4,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = false,
|
loop = false,
|
||||||
|
pitch = 0.75,
|
||||||
},
|
},
|
||||||
engine_stop = {
|
engine_stop = {
|
||||||
gain = 0.8,
|
sound_name = "sum_airship_lip_trill_end",
|
||||||
|
gain = 2.2,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = false,
|
loop = false,
|
||||||
},
|
},
|
||||||
engine_boost = {
|
engine_boost = {
|
||||||
gain = 1,
|
sound_name = "sum_airship_lip_trill",
|
||||||
|
gain = 40,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = false,
|
loop = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function boat.sound_play(self, name, sound_params)
|
function boat.sound_play(self, sound_obj, sound_instance)
|
||||||
local params = sound_params
|
local params = sound_obj
|
||||||
params.object = self.object
|
params.object = self.object
|
||||||
return minetest.sound_play(name, params)
|
sound_instance.handle = minetest.sound_play(sound_obj.sound_name, params)
|
||||||
|
sound_instance.playing = true
|
||||||
|
sound_instance.time_elapsed = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function boat.update_sound(self, dtime)
|
function boat.sound_stop(sound_instance)
|
||||||
|
if sound_instance.handle then
|
||||||
|
minetest.sound_stop(sound_instance.handle)
|
||||||
|
end
|
||||||
|
sound_instance.playing = false
|
||||||
|
sound_instance.time_elapsed = 0
|
||||||
|
sound_instance.handle = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function boat.update_sound(self, dtime, forward)
|
||||||
local fuel = self._fuel
|
local fuel = self._fuel
|
||||||
|
local is_thrust = forward ~= 0 and self._driver
|
||||||
if not fuel or not type(fuel) == "number" then return false end
|
if not fuel or not type(fuel) == "number" then return false end
|
||||||
if fuel > 2 then
|
|
||||||
if self._sounds.engine.time_elapsed > 2.1
|
if self._sounds.engine.time_elapsed > 2.1
|
||||||
and self._sounds.engine.handle
|
and self._sounds.engine.handle
|
||||||
and self._sounds.engine.playing then
|
and self._sounds.engine.playing then
|
||||||
minetest.sound_stop(self._sounds.engine.handle)
|
boat.sound_stop(self._sounds.engine)
|
||||||
self._sounds.engine.playing = false
|
end
|
||||||
self._sounds.engine.time_elapsed = 0
|
if not self._sounds.engine.playing then
|
||||||
|
if self._fuel > 1 then
|
||||||
|
boat.sound_play(self, sounds.engine_boost, self._sounds.engine)
|
||||||
|
elseif is_thrust then
|
||||||
|
boat.sound_play(self, sounds.engine_idle, self._sounds.engine)
|
||||||
end
|
end
|
||||||
if not self._sounds.engine.playing then
|
if self._fuel > 1 and self._sounds.engine_stop.playing then
|
||||||
self._sounds.engine.playing = true
|
boat.sound_stop(self._sounds.engine_stop)
|
||||||
self._sounds.engine.time_elapsed = 0
|
|
||||||
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
|
end
|
||||||
elseif self._sounds.engine.playing
|
end
|
||||||
and self._sounds.engine_stop.time_elapsed then
|
|
||||||
minetest.sound_stop(self._sounds.engine.handle)
|
if self._fuel <= 1 and self._sounds.engine.playing then
|
||||||
self._sounds.engine.playing = false
|
if self._fuel > 0 and not self._sounds.engine_stop.playing
|
||||||
if not self._sounds.engine_stop.playing then
|
and self._sounds.engine_stop.time_elapsed == 0 then
|
||||||
self._sounds.engine_stop.playing = true
|
boat.sound_play(self, sounds.engine_stop, self._sounds.engine_stop)
|
||||||
self._sounds.engine_stop.time_elapsed = 0
|
end
|
||||||
self._sounds.engine_stop.handle = boat.sound_play(self, "sum_airship_lip_trill_end", sounds.engine_stop)
|
if not is_thrust
|
||||||
|
or (self._sounds.engine_stop.time_elapsed == 0
|
||||||
|
and self._sounds.engine_stop.playing) then
|
||||||
|
boat.sound_stop(self._sounds.engine)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -264,6 +280,11 @@ function boat.on_rightclick(self, clicker)
|
||||||
clicker:set_wielded_item(item)
|
clicker:set_wielded_item(item)
|
||||||
end
|
end
|
||||||
self._fuel = self._fuel + sum_airship.fuel_time
|
self._fuel = self._fuel + sum_airship.fuel_time
|
||||||
|
boat.sound_stop(self._sounds.engine)
|
||||||
|
minetest.sound_play("sum_airship_fire", {
|
||||||
|
gain = 1,
|
||||||
|
object = self.object,
|
||||||
|
})
|
||||||
elseif self._passenger or not clicker or clicker:get_attach() then
|
elseif self._passenger or not clicker or clicker:get_attach() then
|
||||||
else
|
else
|
||||||
attach_object(self, clicker)
|
attach_object(self, clicker)
|
||||||
|
@ -516,11 +537,13 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
|
|
||||||
local chimney_pos = boat.get_chimney_pos(self)
|
local chimney_pos = boat.get_chimney_pos(self)
|
||||||
if true or has_controls then -- only do it if you got the input
|
if true or has_controls then -- only do it if you got the input
|
||||||
boat.update_sound(self, dtime)
|
boat.update_sound(self, dtime, forward)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local is_thrust = self._driver and forward ~= 0
|
||||||
|
|
||||||
local spread = 0.06
|
local spread = 0.06
|
||||||
if self._fuel > 0 or math.random(0,100) > 80 then
|
if self._fuel > 0 or (math.random(0,100) > 80 and is_thrust) or math.random(0,100) > 95 then
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = vector.offset(chimney_pos, math.random(-1, 1)*spread, 0, math.random(-1, 1)*spread),
|
pos = vector.offset(chimney_pos, math.random(-1, 1)*spread, 0, math.random(-1, 1)*spread),
|
||||||
velocity = vector.add(wind_vel, {x=0, y=math.random(0.2*100,0.7*100)/100, z=0}),
|
velocity = vector.add(wind_vel, {x=0, y=math.random(0.2*100,0.7*100)/100, z=0}),
|
||||||
|
@ -534,7 +557,7 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
-- animations
|
-- animations
|
||||||
if self._fuel > 0 then
|
if self._fuel > 0 then
|
||||||
self.object:set_animation(self.animations.boost, 25)
|
self.object:set_animation(self.animations.boost, 25)
|
||||||
elseif self._driver then
|
elseif is_thrust then
|
||||||
self.object:set_animation(self.animations.fly, 25)
|
self.object:set_animation(self.animations.fly, 25)
|
||||||
else
|
else
|
||||||
self.object:set_animation(self.animations.idle, 25)
|
self.object:set_animation(self.animations.idle, 25)
|
||||||
|
|
BIN
sounds/sum_airship_fire.ogg
Normal file
BIN
sounds/sum_airship_fire.ogg
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue