From 5732aee94bf597af174d023d29a85a1d586e6ed3 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Sat, 4 Jul 2020 16:06:34 -0400 Subject: [PATCH] Fix limiter causing problems --- mods/minecart/init.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mods/minecart/init.lua b/mods/minecart/init.lua index f94c3fa..87f3360 100644 --- a/mods/minecart/init.lua +++ b/mods/minecart/init.lua @@ -151,24 +151,24 @@ minecart.on_step = function(self,dtime) local pos = vector.round(float_pos) if self.velocity then - local new_vel = dtime/0.01 - --print(new_vel) + local new_vel = dtime/0.01 local test = vector.multiply(self.velocity,new_vel) + --print(dump(test)) - if test.x >= 0.5 then - test.x = 0.4999999999 - elseif test.x <= -0.5 then - test.x = -0.4999999999 + if test.x > 0.5 then + test.x = 0.5 + elseif test.x < -0.5 then + test.x = -0.5 end - if test.z >= 0.5 then - test.z = 0.4999999999 - elseif test.z <= -0.5 then - test.z = -0.4999999999 + if test.z > 0.5 then + test.z = 0.5 + elseif test.z < -0.5 then + test.z = -0.5 end self.object:move_to(vector.add(float_pos,test)) - self.velocity = test end + --stop minecarts from derailing when going super fast if self.old_pos and vector.distance(float_pos,self.old_pos) > 0.5 then self.object:move_to(self.old_pos) -- 2.44.0