mirror of
https://codeberg.org/SumianVoice/sum_airship.git
synced 2025-03-22 15:42:21 +00:00
fix instancing issue
This commit is contained in:
parent
b108328085
commit
4aa98185f8
1 changed files with 27 additions and 25 deletions
50
init.lua
50
init.lua
|
@ -191,19 +191,25 @@ local sounds = {
|
||||||
gain = 2.2,
|
gain = 2.2,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = false,
|
loop = false,
|
||||||
|
pitch = 1,
|
||||||
},
|
},
|
||||||
engine_boost = {
|
engine_boost = {
|
||||||
sound_name = "sum_airship_lip_trill",
|
sound_name = "sum_airship_lip_trill",
|
||||||
gain = 40,
|
gain = 40,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = false,
|
loop = false,
|
||||||
|
pitch = 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function boat.sound_play(self, sound_obj, sound_instance)
|
function boat.sound_play(self, sound_obj, sound_instance)
|
||||||
local params = sound_obj
|
sound_instance.handle = minetest.sound_play(sound_obj.sound_name, {
|
||||||
params.object = self.object
|
gain = sound_obj.gain,
|
||||||
sound_instance.handle = minetest.sound_play(sound_obj.sound_name, params)
|
max_hear_distance = sound_obj.max_hear_distance,
|
||||||
|
loop = sound_obj.loop,
|
||||||
|
pitch = sound_obj.pitch or 1,
|
||||||
|
object = self.object,
|
||||||
|
})
|
||||||
sound_instance.playing = true
|
sound_instance.playing = true
|
||||||
sound_instance.time_elapsed = 0
|
sound_instance.time_elapsed = 0
|
||||||
end
|
end
|
||||||
|
@ -220,7 +226,7 @@ end
|
||||||
function boat.update_sound(self, dtime, forward)
|
function boat.update_sound(self, dtime, forward)
|
||||||
local fuel = self._fuel
|
local fuel = self._fuel
|
||||||
local is_thrust = forward ~= 0 and self._driver
|
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 self._fuel = 0 end
|
||||||
|
|
||||||
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
|
||||||
|
@ -251,23 +257,6 @@ function boat.update_sound(self, dtime, forward)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function boat.update_sound(self, forward, dtime)
|
|
||||||
-- if math.abs(forward) > 0 then
|
|
||||||
-- if not self._sounds.engine.playing then
|
|
||||||
-- self._sounds.engine.playing = true
|
|
||||||
-- self._sounds.engine.handle = minetest.sound_play("sum_airship_lip_trill", {
|
|
||||||
-- gain = 0.3,
|
|
||||||
-- object = self.object,
|
|
||||||
-- max_hear_distance = 10,
|
|
||||||
-- loop = true,
|
|
||||||
-- })
|
|
||||||
-- end
|
|
||||||
-- elseif forward == 0 and self._sounds.engine.playing then
|
|
||||||
-- minetest.sound_stop(self._sounds.engine.handle)
|
|
||||||
-- self._sounds.engine.playing = false
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(detach_object)
|
minetest.register_on_respawnplayer(detach_object)
|
||||||
|
|
||||||
function boat.on_rightclick(self, clicker)
|
function boat.on_rightclick(self, clicker)
|
||||||
|
@ -285,7 +274,6 @@ function boat.on_rightclick(self, clicker)
|
||||||
gain = 1,
|
gain = 1,
|
||||||
object = self.object,
|
object = self.object,
|
||||||
})
|
})
|
||||||
elseif self._passenger or not clicker or clicker:get_attach() then
|
|
||||||
else
|
else
|
||||||
attach_object(self, clicker)
|
attach_object(self, clicker)
|
||||||
end
|
end
|
||||||
|
@ -536,9 +524,8 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
self.object:set_acceleration(vel)
|
self.object:set_acceleration(vel)
|
||||||
|
|
||||||
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
|
|
||||||
boat.update_sound(self, dtime, forward)
|
boat.update_sound(self, dtime, forward)
|
||||||
end
|
|
||||||
|
|
||||||
local is_thrust = self._driver and forward ~= 0
|
local is_thrust = self._driver and forward ~= 0
|
||||||
|
|
||||||
|
@ -619,6 +606,21 @@ for b=1, #boat_ids do
|
||||||
end
|
end
|
||||||
local boat = minetest.add_entity(pos, "sum_airship:boat")
|
local boat = minetest.add_entity(pos, "sum_airship:boat")
|
||||||
local texture = "sum_airship_texture_"..images[b].."_boat.png"
|
local texture = "sum_airship_texture_"..images[b].."_boat.png"
|
||||||
|
local luaent = boat:get_luaentity()
|
||||||
|
luaent._sounds = { -- workaround for copy vs reference issue
|
||||||
|
engine = {
|
||||||
|
handle = nil,
|
||||||
|
gain = 0.1,
|
||||||
|
playing = false,
|
||||||
|
time_elapsed = 0,
|
||||||
|
},
|
||||||
|
engine_stop = {
|
||||||
|
handle = nil,
|
||||||
|
gain = 0.1,
|
||||||
|
playing = false,
|
||||||
|
time_elapsed = 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
boat:get_luaentity()._itemstring = itemstring
|
boat:get_luaentity()._itemstring = itemstring
|
||||||
boat:set_properties({textures = { texture, texture, texture, texture, texture }})
|
boat:set_properties({textures = { texture, texture, texture, texture, texture }})
|
||||||
boat:set_yaw(placer:get_look_horizontal())
|
boat:set_yaw(placer:get_look_horizontal())
|
||||||
|
|
Loading…
Add table
Reference in a new issue