summaryrefslogtreecommitdiff
path: root/advtrains_train_subway/init.lua
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
commitb9aa90a22c25193e2652162ea067c6a9cca05270 (patch)
treeebb3825fb52715c6e92c18ebf526dc5d2a489800 /advtrains_train_subway/init.lua
parent9ff0cdfd9d2355fea2b9ae52b1d7414d4917310a (diff)
downloadbasic_trains-b9aa90a22c25193e2652162ea067c6a9cca05270.tar.gz
basic_trains-b9aa90a22c25193e2652162ea067c6a9cca05270.tar.bz2
basic_trains-b9aa90a22c25193e2652162ea067c6a9cca05270.zip
Don't use looped sounds on subway
(causes engine bugs with dangling sound handles)
Diffstat (limited to 'advtrains_train_subway/init.lua')
-rw-r--r--advtrains_train_subway/init.lua10
1 files changed, 7 insertions, 3 deletions
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")