rewrote system for more types. old designs are incompatible with this tho.
This commit is contained in:
23
src/main.lua
23
src/main.lua
@@ -92,9 +92,11 @@ local function newdesign()
|
|||||||
for z=1+camy,dimensions["z"]+camy,1 do
|
for z=1+camy,dimensions["z"]+camy,1 do
|
||||||
local currentbuf = buf[posasstring(x-camx, currentfloor, z-camy)]
|
local currentbuf = buf[posasstring(x-camx, currentfloor, z-camy)]
|
||||||
term.setCursorPos(x, z)
|
term.setCursorPos(x, z)
|
||||||
if currentbuf then
|
if currentbuf == 1 then -- wall
|
||||||
term.blit(" ", colors.toBlit(colors.white), colors.toBlit(colors.white))
|
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))
|
term.blit("\127", colors.toBlit(colors.gray), colors.toBlit(colors.black))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -115,10 +117,13 @@ local function newdesign()
|
|||||||
event[4] = event[4]+camy
|
event[4] = event[4]+camy
|
||||||
if event[3] <= dimensions["x"] and event[4] <= dimensions["z"] then
|
if event[3] <= dimensions["x"] and event[4] <= dimensions["z"] then
|
||||||
if event[2] == 1 then -- left button, set
|
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
|
end
|
||||||
if event[2] == 2 then -- right button, erase
|
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
|
end
|
||||||
end
|
end
|
||||||
@@ -259,7 +264,7 @@ local function place(direction)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function placebuf(buf, x, y, z)
|
local function placebuf(buf, x, y, z)
|
||||||
if buf[posasstring(x,y,z)] then
|
if buf[posasstring(x,y,z)] == 1 then
|
||||||
place("down")
|
place("down")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -268,7 +273,7 @@ local function printdes(buf, dimensions)
|
|||||||
move("forward")
|
move("forward")
|
||||||
|
|
||||||
for cy=1,dimensions["y"],1 do
|
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 cz=1,dimensions["z"],1 do
|
||||||
for cx=1,dimensions["x"],1 do
|
for cx=1,dimensions["x"],1 do
|
||||||
placebuf(buf, cx, cy, cz)
|
placebuf(buf, cx, cy, cz)
|
||||||
@@ -294,9 +299,11 @@ local function printdes(buf, dimensions)
|
|||||||
move("up")
|
move("up")
|
||||||
end
|
end
|
||||||
-- build ceiling/floor
|
-- build ceiling/floor
|
||||||
for _=1,dimensions["z"],1 do
|
for cz=1,dimensions["z"],1 do
|
||||||
for _=1,dimensions["x"],1 do
|
for cx=1,dimensions["x"],1 do
|
||||||
|
if buf[posasstring(cx,cy,cz)] ~= 2 then
|
||||||
place("down")
|
place("down")
|
||||||
|
end
|
||||||
move("forward")
|
move("forward")
|
||||||
end
|
end
|
||||||
-- return to standard pos but +1 to z
|
-- return to standard pos but +1 to z
|
||||||
|
|||||||
Reference in New Issue
Block a user