add rendering to hopefully make debugging easier

This commit is contained in:
Justus Wolff
2026-02-15 19:56:58 +01:00
parent 475c0f33bd
commit aed59c4863

View File

@@ -306,12 +306,12 @@ local function center(direction, wanted)
end
local function moveto(x,y,cx,cz,direction)
while x ~= cx or y ~= cz do
if x > cx then -- x
if cx < x then -- x
center(direction)
cx = cx + 1
move("forward")
end
if x < cx then
if cx > x then
center(direction)
cx = cx - 1
move("back")
@@ -345,6 +345,26 @@ local function printdes(buf, dimensions)
while true do
local target = getnearestunplaced(buf, pbuf, cx,cy,cz,nil, dimensions["x"],dimensions["z"], false)
if not target then break end
reset() -- render current work
for x=1,dimensions["x"],1 do
for z=1,dimensions["z"],1 do
local currentbuf = pbuf[posasstring(x, cy, z)]
term.setCursorPos(x, z)
if currentbuf then -- wall
term.blit(" ", colors.toBlit(colors.white), colors.toBlit(colors.white))
elseif currentbuf == false or currentbuf == nil then -- nothing
term.blit("\127", colors.toBlit(colors.gray), colors.toBlit(colors.black))
end
end
end
term.setCursorPos(cx,cz)
term.blit(" ", colors.toBlit(colors.red), colors.toBlit(colors.red))
term.setCursorPos(target[1],target[2])
term.blit(" ", colors.toBlit(colors.lime), colors.toBlit(colors.lime))
read("")
cx,cz,direction = moveto(target[1],target[2],cx,cz,direction)
place("down")
pbuf[posasstring(cx,cy,cz)] = true