]> git.lizzy.rs Git - Crafter.git/commitdiff
Add in ability to turn train around
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 5 Jul 2020 22:05:04 +0000 (18:05 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 5 Jul 2020 22:05:04 +0000 (18:05 -0400)
mods/train/init.lua

index 91809e531b2d72d33963a80a98ca47291b0a13ec..53127128f68b481791b36209d6c61c798d8eef82 100644 (file)
@@ -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