diff options
-rwxr-xr-x | init.lua | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -53,8 +53,8 @@ advtrains.register_wagon("diesel_lokomotive", { amount = 10, time = 0, -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base - minpos = {x=0, y=2, z=1.2}, - maxpos = {x=0, y=2, z=1.2}, + minpos = {x=0, y=2.5, z=0.9}, + maxpos = {x=0, y=2.5, z=0.9}, minvel = {x=-0.2, y=1.8, z=-0.2}, maxvel = {x=0.2, y=2, z=0.2}, minacc = {x=0, y=-0.1, z=0}, @@ -77,6 +77,34 @@ advtrains.register_wagon("diesel_lokomotive", { end, drops={"advtrains:diesel_lokomotive"}, horn_sound = "advtrains_engine_diesel_horn", + 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 + if self.sndh then + minetest.sound_stop(self.sndh) + end + self.sndh = minetest.sound_play({name="advtrains_engine_diesel_sound", gain=0.5}, {object = self.object}) + end + +-- if velocity < 2 and (old_velocity >= 2 or old_velocity == velocity) and not self.sound_arrive_handle then +-- --self.sound_arrive_handle = minetest.sound_play("advtrains_subway_arrive", {object = self.object}) +-- elseif (velocity > old_velocity) and self.sound_arrive_handle then +-- minetest.sound_stop(self.sound_arrive_handle) +-- self.sound_arrive_handle = nil +-- end +-- if velocity > 0 and (self.sound_loop_tmr or 0)<=0 then +-- self.sound_loop_handle = minetest.sound_play({name="advtrains_engine_diesel_sound", 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("Diesel Engine"), "advtrains_engine_diesel_inv.png") advtrains.register_wagon("wagon_gravel", { |