added set/erase at newdesign

This commit is contained in:
Justus Wolff
2026-02-15 10:58:55 +01:00
parent ab12e4122f
commit 61af7d59bd

View File

@@ -53,9 +53,63 @@ local function selopt(options, title)
end
end
end
local function integritycheck()
if not fs.exists("designs") then
fs.makeDir("designs")
end
end
local function posasstring(...)
local positions = {...}
local out = ""
for _,v in pairs(positions) do
out = out .. tostring(v) .. ":"
end
return out
end
local function newdesign()
local buf = {}
local dimensions = {
x = 8,
z = 8,
y = 1
}
local currentfloor = 1
local action = selopt({
while true do
-- render buf
reset()
for x=1,dimensions["x"],1 do
for z=1,dimensions["z"],1 do
local currentbuf = buf[posasstring(x, currentfloor, z)]
if currentbuf then
term.setCursorPos(x, z)
term.blit(" ", colors.toBlit(colors.white), colors.toBlit(colors.white))
end
end
end
-- user input
local event = table.pack(os.pullEvent())
if event[1] == "mouse_click" then
if event[2] == 1 then -- left button, set
buf[posasstring(event[3], currentfloor, event[4])] = true
end
if event[2] == 2 then -- right button, erase
buf[posasstring(event[3], currentfloor, event[4])] = false
end
end
end
end
while true do
integritycheck()
local action = selopt({
"New Design",
"Print Design"
}, "Select Action")
}, "Select Action")
if action == 1 then
newdesign()
end
end