Check for regular behavior too

- HAAAAAAAANDS
This commit is contained in:
SmallJoker 2016-07-04 20:56:49 +02:00
parent d63f8ae024
commit cbe0ab9770
2 changed files with 15 additions and 12 deletions

View File

@ -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

View File

@ -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,7 +268,16 @@ 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
-- 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)
@ -276,13 +285,6 @@ function boost_cart.cart:on_step(dtime)
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
update.vel = true
end
end
if self.punched then
-- Collect dropped items