From 392af4281f34cacb882d7dc63997aedf1b181a98 Mon Sep 17 00:00:00 2001 From: YouniS Bensalah Date: Wed, 6 Jan 2016 06:13:08 +0100 Subject: [PATCH] Carts mod patch. Fix #366 Hack that makes sure cart doesn't leave rails and hangs in the air. This patch now seems to fix that. (thx for testing with me @fabienwang) --- mods/carts/init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mods/carts/init.lua b/mods/carts/init.lua index ad1f464a..50bd9775 100755 --- a/mods/carts/init.lua +++ b/mods/carts/init.lua @@ -242,6 +242,23 @@ function cart:calc_rail_direction(pos, vel) p = cart_func.v3:add(p, {x=0, y=-1, z=0}) return self:calc_rail_direction(p, vel) end + -- NOW the hack gets even dirtier + if cart_func:is_rail(cart_func.v3:add(p, {x=0, y=3, z=0})) and vel.y >= 0 then + p = cart_func.v3:add(p, {x=0, y=1, z=0}) + return self:calc_rail_direction(p, vel) + end + if cart_func:is_rail(cart_func.v3:add(p, {x=0, y=-3, z=0})) and vel.y <= 0 then + p = cart_func.v3:add(p, {x=0, y=-1, z=0}) + return self:calc_rail_direction(p, vel) + end + if cart_func:is_rail(cart_func.v3:add(p, {x=0, y=4, z=0})) and vel.y >= 0 then + p = cart_func.v3:add(p, {x=0, y=1, z=0}) + return self:calc_rail_direction(p, vel) + end + if cart_func:is_rail(cart_func.v3:add(p, {x=0, y=-4, z=0})) and vel.y <= 0 then + p = cart_func.v3:add(p, {x=0, y=-1, z=0}) + return self:calc_rail_direction(p, vel) + end return {x=0, y=0, z=0}, p end