diff --git a/src/main.lua b/src/main.lua index 505dad9..4057625 100644 --- a/src/main.lua +++ b/src/main.lua @@ -293,12 +293,16 @@ local function getnearestunplaced(buf, pbuf, cx,cy,cz,co, sx,sz, setceiling) return selected end local function center(direction, wanted) - if direction == 1 and wanted ~= 1 then - move("left") - end - if direction == -1 and wanted ~= -1 then - move("right") - end + if direction == 1 and wanted ~= 1 then + move("left") + return true + end + if direction == -1 and wanted ~= -1 then + move("right") + return true + end + if direction == 0 then return true end + return false end local function moveto(x,y,cx,cz,direction) while x ~= cx or y ~= cz do @@ -314,16 +318,14 @@ local function moveto(x,y,cx,cz,direction) end if y > cz then -- z - center(direction, 1) + if center(direction, 1) then move("right") end cz = cz + 1 - move("right") move("forward") direction = 1 end if y < cz then - center(direction, -1) + if center(direction, -1) then move("left") end cz = cz - 1 - move("left") move("forward") direction = -1 end