2026-02-14 22:07:35 +01:00
|
|
|
-- https://git.l--n.de/justuswolff/cc_housebuild/raw/branch/main/src/main.lua
|
|
|
|
|
|
|
|
|
|
if not _G["turtle"] then
|
|
|
|
|
error("This program only runs on turtles!")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local turtle = _G["turtle"]
|
|
|
|
|
|
2026-02-14 22:24:37 +01:00
|
|
|
print("House building system")
|
|
|
|
|
print("JUFS Technologies (c) 2026 (Justus Wolff)")
|
|
|
|
|
|
2026-02-14 22:07:35 +01:00
|
|
|
print("fuel: "..tostring(turtle.getFuelLevel()).."/"..tostring(turtle.getFuelLimit()))
|
|
|
|
|
|
2026-02-14 22:24:37 +01:00
|
|
|
local function reset()
|
|
|
|
|
term.clear()
|
|
|
|
|
term.setCursorPos(1,1)
|
|
|
|
|
end
|
|
|
|
|
local function incline()
|
2026-02-14 22:25:53 +01:00
|
|
|
local _,y = term.getCursorPos()
|
|
|
|
|
term.setCursorPos(1,y+1)
|
2026-02-14 22:24:37 +01:00
|
|
|
end
|
|
|
|
|
function term.setcol(fc, bc)
|
|
|
|
|
term.setTextColor(fc)
|
|
|
|
|
term.setBackgroundColor(bc)
|
|
|
|
|
end
|
|
|
|
|
local function selopt(options, title)
|
|
|
|
|
reset()
|
|
|
|
|
term.setcol(colors.black, colors.white)
|
|
|
|
|
term.write(title)
|
|
|
|
|
|
|
|
|
|
local selected = 1
|
|
|
|
|
|
|
|
|
|
while true do
|
|
|
|
|
for i,v in pairs(options) do
|
|
|
|
|
incline()
|
|
|
|
|
if i == selected then
|
|
|
|
|
term.setcol(colors.black, colors.blue)
|
|
|
|
|
else
|
|
|
|
|
term.setcol(colors.white, colors.black)
|
|
|
|
|
end
|
|
|
|
|
term.write(v)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local event,key = os.pullEvent("key")
|
|
|
|
|
if keys.getName(key) == "w" and selected ~= 1 then
|
|
|
|
|
selected = selected - 1
|
|
|
|
|
end
|
|
|
|
|
if keys.getName(key) == "s" and selected ~= #options then
|
|
|
|
|
selected = selected + 1
|
|
|
|
|
end
|
|
|
|
|
if keys.getName(key) == "enter" then
|
|
|
|
|
return selected
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local action = selopt({
|
|
|
|
|
"New Design",
|
|
|
|
|
"Print Design"
|
|
|
|
|
}, "Select Action")
|
|
|
|
|
|