Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local w, h = term.getSize()
- function printCentered(y, s)
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x, y)
- term.clearLine()
- term.write(s)
- end
- local nOption = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1, 1)
- term.write("V: 0.1")
- term.setCursorPos(1, 2)
- term.setCursorPos(w - 11, 1)
- local options = { "Miner", "Lumber", "Stats", "Menu" }
- term.write(options[nOption] or "")
- end
- local function drawFrontend()
- printCentered(math.floor(h / 2) - 3, "")
- printCentered(math.floor(h / 2) - 2, "Programms")
- printCentered(math.floor(h / 2) - 1, "")
- printCentered(math.floor(h / 2) + 0, (nOption == 1 and "[ Miner ]") or "Miner")
- printCentered(math.floor(h / 2) + 1, (nOption == 2 and "[ Lumber ]") or "Lumber")
- printCentered(math.floor(h / 2) + 2, (nOption == 3 and "[ Stats ]") or "Stats")
- printCentered(math.floor(h / 2) + 3, (nOption == 4 and "[ Menu ]") or "Menu")
- printCentered(math.floor(h / 2) + 4, "")
- end
- -- Display
- drawMenu()
- drawFrontend()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.z or key == keys.up then -- "Z" instead of "W" for QWERTZ
- if nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.s or key == keys.down then
- if nOption < 4 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.enter then
- break
- end
- end
- term.clear()
- -- Conditions for selection
- if nOption == 1 then
- shell.run("miner")
- elseif nOption == 2 then
- shell.run("lumber")
- elseif nOption == 3 then
- shell.run("stats")
- elseif nOption == 4 then
- shell.run("menu2")
- end
Advertisement
Add Comment
Please, Sign In to add comment