From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Sat, 4 Jul 2020 01:43:04 +0000 (-0400) Subject: Add in extremely cynical rail checking X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=fbcc67f071eb6ecede926aa7612746bea94a7fee;p=Crafter.git Add in extremely cynical rail checking --- diff --git a/mods/minecart/init.lua b/mods/minecart/init.lua index 108fe7c..a6d46f4 100644 --- a/mods/minecart/init.lua +++ b/mods/minecart/init.lua @@ -52,18 +52,45 @@ local function collision_detect(self) local pos2 = object:get_pos() if self.axis_lock == "x" then local velocity = 1-vector.distance(vector.new(pos.x,0,0),vector.new(pos2.x,0,0)) + print(velocity) local dir = vector.direction(vector.new(pos2.x,0,0),vector.new(pos.x,0,0)) - self.object:add_velocity(dir) + self.object:add_velocity(vector.multiply(dir,velocity)) + self.dir = dir elseif self.axis_lock == "z" then local velocity = 1-vector.distance(vector.new(0,0,pos.z),vector.new(0,0,pos2.z)) local dir = vector.direction(vector.new(0,0,pos2.z),vector.new(0,0,pos.z)) - self.object:add_velocity(dir) + self.object:add_velocity(vector.multiply(dir,velocity)) + self.dir = dir end return end end end + +local function rail_brain(self,pos) + if not self.dir then return end + + if self.dir then print(dump(self.dir)) end + + local pos2 = self.object:get_pos() + + local dir = self.dir + + if dir.x < 0 and pos2.x < pos.x then + print("check dat rail boi") + elseif dir.x > 0 and pos2.x > pos.x then + print("check dat rail boi 2") + elseif dir.z < 0 and pos2.z < pos.z then + print("check dat rail boi 3") + elseif dir.z > 0 and pos2.z > pos.z then + print("wow this actually wurkz") + end +end + + + + local minecart = {} minecart.on_step = function(self,dtime) @@ -81,6 +108,7 @@ minecart.on_step = function(self,dtime) end else collision_detect(self) + rail_brain(self,pos) end end