Carts: Do not connect rails with gunpowder (#1812)
authorSmallJoker <SmallJoker@users.noreply.github.com>
Sun, 2 Jul 2017 08:32:10 +0000 (10:32 +0200)
committersfan5 <sfan5@live.de>
Sun, 19 Nov 2017 21:53:53 +0000 (22:53 +0100)
mods/carts/cart_entity.lua
mods/carts/functions.lua

index a19da64833d5a482561b46ad979db806d54f3397..8f73374602e102c240d2cfe3be1b6bf0b79a0ca4 100644 (file)
@@ -58,7 +58,8 @@ end
 
 function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
        local pos = self.object:getpos()
-       if not self.railtype then
+       local vel = self.object:getvelocity()
+       if not self.railtype or vector.equals(vel, {x=0, y=0, z=0}) then
                local node = minetest.get_node(pos).name
                self.railtype = minetest.get_item_group(node, "connect_to_raillike")
        end
@@ -105,7 +106,6 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
                return
        end
        -- Player punches cart to alter velocity
-       local vel = self.object:getvelocity()
        if puncher:get_player_name() == self.driver then
                if math.abs(vel.x + vel.z) > carts.punch_speed_max then
                        return
index a47171948a8dbabedca691e005a9eee2dfc4db32..96a12d2b50eefe852b0d8bce624494014066215c 100644 (file)
@@ -211,7 +211,12 @@ end
 
 function carts:get_rail_groups(additional_groups)
        -- Get the default rail groups and add more when a table is given
-       local groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}
+       local groups = {
+               dig_immediate = 2,
+               attached_node = 1,
+               rail = 1,
+               connect_to_raillike = minetest.raillike_group("rail")
+       }
        if type(additional_groups) == "table" then
                for k, v in pairs(additional_groups) do
                        groups[k] = v