From 620ca56b952037860b750e87e930754fd1d7b002 Mon Sep 17 00:00:00 2001 From: stujones11 Date: Sat, 16 Jan 2016 18:03:13 +0000 Subject: Fix regression with unloaded carts --- railcart/railcart.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'railcart') diff --git a/railcart/railcart.lua b/railcart/railcart.lua index bdd9a05..68efda5 100644 --- a/railcart/railcart.lua +++ b/railcart/railcart.lua @@ -200,8 +200,10 @@ function railcart:update(cart, time, object) accel = RAILTRACK_ACCEL_UP end accel = cart.accel or accel - local d = dist - RAILCART_SNAP_DISTANCE - local dt = railcart:get_delta_time(speed, accel, d) + if object then + dist = math.max(dist - RAILCART_SNAP_DISTANCE, 0) + end + local dt = railcart:get_delta_time(speed, accel, dist) if dt < time then time = dt end -- cgit v1.2.3