added set/erase at newdesign
This commit is contained in:
54
src/main.lua
54
src/main.lua
@@ -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
|
||||
|
||||
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")
|
||||
|
||||
if action == 1 then
|
||||
newdesign()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user