Skip to content

Commit c51ebcb

Browse files
authoredJul 2, 2017
Carts: Do not connect rails with gunpowder (#1812)
1 parent bae17cd commit c51ebcb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

Diff for: ‎mods/carts/cart_entity.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ end
5858

5959
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
6060
local pos = self.object:getpos()
61-
if not self.railtype then
61+
local vel = self.object:getvelocity()
62+
if not self.railtype or vector.equals(vel, {x=0, y=0, z=0}) then
6263
local node = minetest.get_node(pos).name
6364
self.railtype = minetest.get_item_group(node, "connect_to_raillike")
6465
end
@@ -105,7 +106,6 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
105106
return
106107
end
107108
-- Player punches cart to alter velocity
108-
local vel = self.object:getvelocity()
109109
if puncher:get_player_name() == self.driver then
110110
if math.abs(vel.x + vel.z) > carts.punch_speed_max then
111111
return

Diff for: ‎mods/carts/functions.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ end
211211

212212
function carts:get_rail_groups(additional_groups)
213213
-- Get the default rail groups and add more when a table is given
214-
local groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}
214+
local groups = {
215+
dig_immediate = 2,
216+
attached_node = 1,
217+
rail = 1,
218+
connect_to_raillike = minetest.raillike_group("rail")
219+
}
215220
if type(additional_groups) == "table" then
216221
for k, v in pairs(additional_groups) do
217222
groups[k] = v

0 commit comments

Comments
 (0)
Please sign in to comment.