From fcbb4f6e34cccbd560243571142618e845c308a0 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 9 Nov 2024 12:33:39 -0600 Subject: [PATCH] Fix detector rail strangeness, prevent crash --- mods/ENTITIES/mcl_minecarts/movement.lua | 2 +- mods/ENTITIES/mcl_minecarts/rails/detector.lua | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/movement.lua b/mods/ENTITIES/mcl_minecarts/movement.lua index 2cbfe4ec9..417660e00 100644 --- a/mods/ENTITIES/mcl_minecarts/movement.lua +++ b/mods/ENTITIES/mcl_minecarts/movement.lua @@ -276,7 +276,7 @@ local function calculate_acceleration(staticdata) if (ctrl.forward or 0) > time_active then if staticdata.velocity == 0 then - local look_dir = look_directions[ctrl.look or 0] + local look_dir = look_directions[ctrl.look or 0] or mod.north local dot = vector.dot(staticdata.dir, look_dir) if dot < 0 then reverse_direction(staticdata) diff --git a/mods/ENTITIES/mcl_minecarts/rails/detector.lua b/mods/ENTITIES/mcl_minecarts/rails/detector.lua index b339c9335..80ae596cc 100644 --- a/mods/ENTITIES/mcl_minecarts/rails/detector.lua +++ b/mods/ENTITIES/mcl_minecarts/rails/detector.lua @@ -19,12 +19,8 @@ mod.register_straight_rail("mcl_minecarts:detector_rail_v2",{"mcl_minecarts_rail }, _mcl_minecarts_on_enter = function(pos, cart) local node = minetest.get_node(pos) - - local newnode = { - name = "mcl_minecarts:detector_rail_v2_on", - param2 = node.param2 - } - minetest.swap_node( pos, newnode ) + node.name = "mcl_minecarts:detector_rail_v2_on" + minetest.set_node( pos, node ) mesecon.receptor_on(pos) end, craft = { @@ -51,12 +47,8 @@ mod.register_straight_rail("mcl_minecarts:detector_rail_v2_on",{"mcl_minecarts_r }, _mcl_minecarts_on_leave = function(pos, cart) local node = minetest.get_node(pos) - - local newnode = { - name = "mcl_minecarts:detector_rail", - param2 = node.param2 - } - minetest.swap_node( pos, newnode ) + node.name = "mcl_minecarts:detector_rail_v2" + minetest.set_node( pos, node ) mesecon.receptor_off(pos) end, drop = "mcl_minecarts:detector_rail_v2",