aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-01-07 20:52:15 +0100
committerorwell96 <orwell@bleipb.de>2018-01-07 20:52:15 +0100
commitae88f29481c83532f79dfa55d6ec6eb27e091bb6 (patch)
tree9da2d964b9ae6c181ab3894b7bf031baa98d4eb8
parent1f26781b6a79135159205231f580beb06e789d4d (diff)
downloadadvtrains-ae88f29481c83532f79dfa55d6ec6eb27e091bb6.tar.gz
advtrains-ae88f29481c83532f79dfa55d6ec6eb27e091bb6.tar.bz2
advtrains-ae88f29481c83532f79dfa55d6ec6eb27e091bb6.zip
Don't use looped sounds on subway
(causes engine bugs with dangling sound handles)
-rw-r--r--advtrains/wagons.lua2
-rw-r--r--advtrains_train_subway/init.lua10
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_loop.oggbin19691 -> 33319 bytes
3 files changed, 8 insertions, 4 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index a367487..0616f9f 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -532,7 +532,7 @@ function wagon:on_step(dtime)
self:update_animation(gp.velocity, self.old_velocity)
end
if self.custom_on_velocity_change then
- self:custom_on_velocity_change(gp.velocity, self.old_velocity or 0)
+ self:custom_on_velocity_change(gp.velocity, self.old_velocity or 0, dtime)
end
end
diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua
index 2948fb8..b8dfa4b 100644
--- a/advtrains_train_subway/init.lua
+++ b/advtrains_train_subway/init.lua
@@ -76,7 +76,7 @@ advtrains.register_wagon("subway_wagon", {
is_locomotive=true,
drops={"default:steelblock 4"},
horn_sound = "advtrains_subway_horn",
- custom_on_velocity_change = function(self, velocity, old_velocity)
+ custom_on_velocity_change = function(self, velocity, old_velocity, dtime)
if not velocity or not old_velocity then return end
if old_velocity == 0 and velocity > 0 then
minetest.sound_play("advtrains_subway_depart", {object = self.object})
@@ -87,13 +87,17 @@ advtrains.register_wagon("subway_wagon", {
minetest.sound_stop(self.sound_arrive_handle)
self.sound_arrive_handle = nil
end
- if velocity > 0 and not self.sound_loop_handle then
- self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object, loop=true})
+ if velocity > 0 and (self.sound_loop_tmr or 0)<=0 then
+ self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object})
+ self.sound_loop_tmr=3
+ elseif velocity>0 then
+ self.sound_loop_tmr = self.sound_loop_tmr - dtime
elseif velocity==0 then
if self.sound_loop_handle then
minetest.sound_stop(self.sound_loop_handle)
self.sound_loop_handle = nil
end
+ self.sound_loop_tmr=0
end
end,
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
diff --git a/advtrains_train_subway/sounds/advtrains_subway_loop.ogg b/advtrains_train_subway/sounds/advtrains_subway_loop.ogg
index 1a7021a..2543cc2 100644
--- a/advtrains_train_subway/sounds/advtrains_subway_loop.ogg
+++ b/advtrains_train_subway/sounds/advtrains_subway_loop.ogg
Binary files differ