feat(mystical-upgrader): improve moves
This commit is contained in:
parent
55c8e44a27
commit
3181d68839
@ -59,31 +59,29 @@ local refuel = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local goToTheLeft = function()
|
|
||||||
turtle.turnLeft()
|
|
||||||
local ok, reason = turtle.forward()
|
|
||||||
|
|
||||||
if not ok then
|
|
||||||
error('cannot forward because ' .. tostring(reason), 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
turtle.turnRight()
|
|
||||||
end
|
|
||||||
|
|
||||||
local goToTheRight = function()
|
|
||||||
turtle.turnRight()
|
|
||||||
local ok, reason = turtle.forward()
|
|
||||||
|
|
||||||
if not ok then
|
|
||||||
error('cannot forward because ' .. tostring(reason), 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
turtle.turnLeft()
|
|
||||||
end
|
|
||||||
|
|
||||||
local MOVES = {
|
local MOVES = {
|
||||||
left = goToTheLeft,
|
left = function(strictMode)
|
||||||
right = goToTheRight,
|
turtle.turnLeft()
|
||||||
|
local ok, reason = turtle.forward()
|
||||||
|
|
||||||
|
if strictMode and not ok then
|
||||||
|
error('cannot forward because ' .. tostring(reason), 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
turtle.turnRight()
|
||||||
|
return ok, reason
|
||||||
|
end,
|
||||||
|
right = function(strictMode)
|
||||||
|
turtle.turnRight()
|
||||||
|
local ok, reason = turtle.forward()
|
||||||
|
|
||||||
|
if strictMode and not ok then
|
||||||
|
error('cannot forward because ' .. tostring(reason), 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
turtle.turnLeft()
|
||||||
|
return ok, reason
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local getTierFromLevel = function(level)
|
local getTierFromLevel = function(level)
|
||||||
@ -262,7 +260,9 @@ local main = function()
|
|||||||
upgradeProcedure()
|
upgradeProcedure()
|
||||||
|
|
||||||
if i ~= NB_ROWS then
|
if i ~= NB_ROWS then
|
||||||
MOVES[DIRECTION]()
|
MOVES[DIRECTION](true)
|
||||||
|
else
|
||||||
|
MOVES[DIRECTION](false) -- do not throw if cannot move forward
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user