From 8aa01273f392469b4fc62fac12b1ac848422d78c Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Sun, 5 Jul 2020 18:05:04 -0400 Subject: [PATCH] Add in ability to turn train around --- mods/train/init.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/train/init.lua b/mods/train/init.lua index 91809e5..5312712 100644 --- a/mods/train/init.lua +++ b/mods/train/init.lua @@ -119,7 +119,7 @@ local function direction_snap(self) local yaw = minetest.dir_to_yaw(dir) if self.driver then - self.driver:set_look_vertical(pitch) + self.driver:set_look_vertical(-pitch) self.driver:set_look_horizontal(yaw) end self.object:set_rotation(vector.new(pitch,yaw,0)) @@ -360,7 +360,15 @@ train.on_punch = function(self, puncher) if self.is_engine and puncher:get_player_control().sneak then if vector.equals(self.object:get_velocity(),vector.new(0,0,0)) then - print("reverse direction") + if self.dir.y == 0 then + self.dir = vector.multiply(self.dir,-1) + direction_snap(self) + minetest.sound_play("wrench",{ + object = self.object, + gain = 1.0, + max_hear_distance = 64, + }) + end end return end -- 2.44.0