make center return boolean if centered. (needed for some moveto operations)
This commit is contained in:
22
src/main.lua
22
src/main.lua
@@ -293,12 +293,16 @@ local function getnearestunplaced(buf, pbuf, cx,cy,cz,co, sx,sz, setceiling)
|
|||||||
return selected
|
return selected
|
||||||
end
|
end
|
||||||
local function center(direction, wanted)
|
local function center(direction, wanted)
|
||||||
if direction == 1 and wanted ~= 1 then
|
if direction == 1 and wanted ~= 1 then
|
||||||
move("left")
|
move("left")
|
||||||
end
|
return true
|
||||||
if direction == -1 and wanted ~= -1 then
|
end
|
||||||
move("right")
|
if direction == -1 and wanted ~= -1 then
|
||||||
end
|
move("right")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if direction == 0 then return true end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
local function moveto(x,y,cx,cz,direction)
|
local function moveto(x,y,cx,cz,direction)
|
||||||
while x ~= cx or y ~= cz do
|
while x ~= cx or y ~= cz do
|
||||||
@@ -314,16 +318,14 @@ local function moveto(x,y,cx,cz,direction)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if y > cz then -- z
|
if y > cz then -- z
|
||||||
center(direction, 1)
|
if center(direction, 1) then move("right") end
|
||||||
cz = cz + 1
|
cz = cz + 1
|
||||||
move("right")
|
|
||||||
move("forward")
|
move("forward")
|
||||||
direction = 1
|
direction = 1
|
||||||
end
|
end
|
||||||
if y < cz then
|
if y < cz then
|
||||||
center(direction, -1)
|
if center(direction, -1) then move("left") end
|
||||||
cz = cz - 1
|
cz = cz - 1
|
||||||
move("left")
|
|
||||||
move("forward")
|
move("forward")
|
||||||
direction = -1
|
direction = -1
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user