diff --git a/src/main.lua b/src/main.lua index 3217028..27d8f6e 100644 --- a/src/main.lua +++ b/src/main.lua @@ -92,9 +92,11 @@ local function newdesign() for z=1+camy,dimensions["z"]+camy,1 do local currentbuf = buf[posasstring(x-camx, currentfloor, z-camy)] term.setCursorPos(x, z) - if currentbuf then + if currentbuf == 1 then -- wall term.blit(" ", colors.toBlit(colors.white), colors.toBlit(colors.white)) - else + elseif currentbuf == 2 then -- no ceiling + term.blit(" ", colors.toBlit(colors.red), colors.toBlit(colors.red)) + elseif currentbuf == 0 then -- nothing term.blit("\127", colors.toBlit(colors.gray), colors.toBlit(colors.black)) end end @@ -115,10 +117,13 @@ local function newdesign() event[4] = event[4]+camy if event[3] <= dimensions["x"] and event[4] <= dimensions["z"] then if event[2] == 1 then -- left button, set - buf[posasstring(event[3], currentfloor, event[4])] = true + buf[posasstring(event[3], currentfloor, event[4])] = 1 + end + if event[2] == 3 then -- middle button, set no ceiling + buf[posasstring(event[3], currentfloor, event[4])] = 2 end if event[2] == 2 then -- right button, erase - buf[posasstring(event[3], currentfloor, event[4])] = false + buf[posasstring(event[3], currentfloor, event[4])] = 0 end end end @@ -259,7 +264,7 @@ local function place(direction) end end local function placebuf(buf, x, y, z) - if buf[posasstring(x,y,z)] then + if buf[posasstring(x,y,z)] == 1 then place("down") end end @@ -268,7 +273,7 @@ local function printdes(buf, dimensions) move("forward") for cy=1,dimensions["y"],1 do - for _=1,3,1 do -- build floor + for _=1,3,1 do -- build walls for cz=1,dimensions["z"],1 do for cx=1,dimensions["x"],1 do placebuf(buf, cx, cy, cz) @@ -294,9 +299,11 @@ local function printdes(buf, dimensions) move("up") end -- build ceiling/floor - for _=1,dimensions["z"],1 do - for _=1,dimensions["x"],1 do - place("down") + for cz=1,dimensions["z"],1 do + for cx=1,dimensions["x"],1 do + if buf[posasstring(cx,cy,cz)] ~= 2 then + place("down") + end move("forward") end -- return to standard pos but +1 to z