From 75634babf414e757b58f1a1df2e3a90bd0352486 Mon Sep 17 00:00:00 2001 From: Justus Wolff Date: Sat, 14 Feb 2026 22:24:37 +0100 Subject: [PATCH] selopt test --- src/main.lua | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/main.lua b/src/main.lua index cff9c68..7cc1564 100644 --- a/src/main.lua +++ b/src/main.lua @@ -6,5 +6,56 @@ end local turtle = _G["turtle"] +print("House building system") +print("JUFS Technologies (c) 2026 (Justus Wolff)") + print("fuel: "..tostring(turtle.getFuelLevel()).."/"..tostring(turtle.getFuelLimit())) +local function reset() + term.clear() + term.setCursorPos(1,1) +end +local function incline() + local x,y = term.getCursorPos() + term.setCursorPos(x,y+1) +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") +