make center return boolean if centered. (needed for some moveto operations)

This commit is contained in:
Justus Wolff
2026-02-15 19:48:45 +01:00
parent d2c77b60f1
commit 475c0f33bd

View File

@@ -295,10 +295,14 @@ end
local function center(direction, wanted)
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