make progress rendering a function and show walls that are yet to be placed.
This commit is contained in:
62
src/main.lua
62
src/main.lua
@@ -335,6 +335,34 @@ local function moveto(x,y,cx,cz,direction)
|
||||
end
|
||||
return cx,cz,direction
|
||||
end
|
||||
local function tcontains(x, y)
|
||||
for _,v in pairs(x) do
|
||||
if v == y then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
local function render(buf, pbuf, cx,cy,cz, tx,tz, sx,sz, shouldsetlist,invertslist)
|
||||
shouldsetlist = shouldsetlist or {
|
||||
1,
|
||||
}
|
||||
|
||||
reset()
|
||||
for x=1,sx,1 do
|
||||
for z=1,sz,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) and (invertslist and not tcontains(shouldsetlist, buf[posasstring(x, cy, z)]) or tcontains(shouldsetlist, buf[posasstring(x, cy, z)])) 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(tx,tz)
|
||||
term.blit(" ", colors.toBlit(colors.lime), colors.toBlit(colors.lime))
|
||||
end
|
||||
local function printdes(buf, dimensions)
|
||||
move("up")
|
||||
move("forward")
|
||||
@@ -349,22 +377,7 @@ local function printdes(buf, dimensions)
|
||||
local target = getnearestunplaced(buf, pbuf, cx,cy,cz,nil, dimensions["x"],dimensions["z"])
|
||||
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))
|
||||
render(buf, pbuf, cx,cy,cz, target[1],target[2], dimensions["x"],dimensions["z"], {1})
|
||||
|
||||
--read("")
|
||||
|
||||
@@ -390,22 +403,7 @@ local function printdes(buf, dimensions)
|
||||
local target = getnearestunplaced(cbuf, pbuf, cx,0,cz,nil, dimensions["x"],dimensions["z"])
|
||||
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, 0, 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))
|
||||
render(cbuf, pbuf, cx,0,cz, target[1],target[2], dimensions["x"],dimensions["z"], {1})
|
||||
|
||||
cx,cz,direction = moveto(target[1],target[2],cx,cz,direction)
|
||||
place("down")
|
||||
|
||||
Reference in New Issue
Block a user