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
|
end
|
||||||
return cx,cz,direction
|
return cx,cz,direction
|
||||||
end
|
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)
|
local function printdes(buf, dimensions)
|
||||||
move("up")
|
move("up")
|
||||||
move("forward")
|
move("forward")
|
||||||
@@ -349,22 +377,7 @@ local function printdes(buf, dimensions)
|
|||||||
local target = getnearestunplaced(buf, pbuf, cx,cy,cz,nil, dimensions["x"],dimensions["z"])
|
local target = getnearestunplaced(buf, pbuf, cx,cy,cz,nil, dimensions["x"],dimensions["z"])
|
||||||
if not target then break end
|
if not target then break end
|
||||||
|
|
||||||
reset() -- render current work
|
render(buf, pbuf, cx,cy,cz, target[1],target[2], dimensions["x"],dimensions["z"], {1})
|
||||||
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("")
|
--read("")
|
||||||
|
|
||||||
@@ -390,22 +403,7 @@ local function printdes(buf, dimensions)
|
|||||||
local target = getnearestunplaced(cbuf, pbuf, cx,0,cz,nil, dimensions["x"],dimensions["z"])
|
local target = getnearestunplaced(cbuf, pbuf, cx,0,cz,nil, dimensions["x"],dimensions["z"])
|
||||||
if not target then break end
|
if not target then break end
|
||||||
|
|
||||||
reset() -- render current work
|
render(cbuf, pbuf, cx,0,cz, target[1],target[2], dimensions["x"],dimensions["z"], {1})
|
||||||
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))
|
|
||||||
|
|
||||||
cx,cz,direction = moveto(target[1],target[2],cx,cz,direction)
|
cx,cz,direction = moveto(target[1],target[2],cx,cz,direction)
|
||||||
place("down")
|
place("down")
|
||||||
|
|||||||
Reference in New Issue
Block a user