forked from mtcontrib/boost_cart
Check for regular behavior too
- HAAAAAAAANDS
This commit is contained in:
parent
d63f8ae024
commit
cbe0ab9770
|
@ -163,6 +163,11 @@ function boost_cart:pathfinder(pos_, expected_pos, old_dir, ctrl, pf_switch, rai
|
|||
local pf_dir = vector.new(old_dir)
|
||||
|
||||
for i = 1, 3 do
|
||||
if vector.equals(pf_pos, pos) then
|
||||
-- Success! Cart moved on correctly
|
||||
return true
|
||||
end
|
||||
|
||||
pf_dir, pf_switch = boost_cart:get_rail_direction(pf_pos, pf_dir, ctrl, pf_switch, railtype)
|
||||
if vector.equals(pf_dir, {x=0, y=0, z=0}) then
|
||||
-- No way forwards
|
||||
|
@ -170,10 +175,6 @@ function boost_cart:pathfinder(pos_, expected_pos, old_dir, ctrl, pf_switch, rai
|
|||
end
|
||||
|
||||
pf_pos = vector.add(pf_pos, pf_dir)
|
||||
if vector.equals(pf_pos, pos) then
|
||||
-- Success! Cart moved on correctly
|
||||
return true
|
||||
end
|
||||
end
|
||||
-- Cart not found
|
||||
return false
|
||||
|
|
18
init.lua
18
init.lua
|
@ -168,8 +168,8 @@ function boost_cart.cart:on_step(dtime)
|
|||
local pos = self.object:getpos()
|
||||
|
||||
if self.old_pos and not self.punched then
|
||||
local flo_pos = vector.floor(pos)
|
||||
local flo_old = vector.floor(self.old_pos)
|
||||
local flo_pos = vector.round(pos)
|
||||
local flo_old = vector.round(self.old_pos)
|
||||
if vector.equals(flo_pos, flo_old) then
|
||||
-- Do not check one node multiple times
|
||||
return
|
||||
|
@ -268,21 +268,23 @@ function boost_cart.cart:on_step(dtime)
|
|||
end
|
||||
|
||||
if mesecon then
|
||||
boost_cart:signal_detector_rail(vector.floor(pos))
|
||||
boost_cart:signal_detector_rail(vector.round(pos))
|
||||
end
|
||||
|
||||
self.object:setacceleration(new_acc)
|
||||
self.old_pos = vector.new(pos)
|
||||
self.old_dir = vector.new(dir)
|
||||
self.old_switch = last_switch
|
||||
|
||||
-- Limits
|
||||
for _,v in ipairs({"x","y","z"}) do
|
||||
if math.abs(vel[v]) > max_vel then
|
||||
vel[v] = boost_cart:get_sign(vel[v]) * max_vel
|
||||
new_acc[v] = 0
|
||||
update.vel = true
|
||||
end
|
||||
end
|
||||
|
||||
self.object:setacceleration(new_acc)
|
||||
self.old_pos = vector.new(pos)
|
||||
self.old_dir = vector.new(dir)
|
||||
self.old_switch = last_switch
|
||||
|
||||
|
||||
if self.punched then
|
||||
-- Collect dropped items
|
||||
|
|
Loading…
Reference in New Issue
Block a user