From af25c5411b0be5b4fd2ac8b49378a62440376f8e Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 1 Jul 2017 10:45:15 +0200 Subject: [PATCH] Use minetest.raillike_group, do not connect rails with other raillike --- cart_entity.lua | 5 +++-- functions.lua | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cart_entity.lua b/cart_entity.lua index 4147c09..257aae6 100644 --- a/cart_entity.lua +++ b/cart_entity.lua @@ -83,7 +83,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 @@ -122,7 +123,7 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, return end - local vel = self.object:getvelocity() + -- Driver punches to accelerate the cart if puncher:get_player_name() == self.driver then if math.abs(vel.x + vel.z) > boost_cart.punch_speed_max then return diff --git a/functions.lua b/functions.lua index 9876eb2..9e3050a 100644 --- a/functions.lua +++ b/functions.lua @@ -217,7 +217,15 @@ end function boost_cart: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 = 1 + } + if minetest.raillike_group then + groups.connect_to_raillike = minetest.raillike_group("rail") + end if type(additional_groups) == "table" then for k, v in pairs(additional_groups) do groups[k] = v