Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --save as .menu in main dir
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function printCentred (y,s)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x, y)
- term.clearLine()
- term.write(s)
- end
- local choose = 1
- --Menu
- local function drawMenu()
- clear()
- term.write("---Rauten Os v.001---")
- term.setCursorPos(1, 2)
- shell.run("id")
- term.setCursorPos(w-11,1)
- if choose == 1 then
- term.write("Desktop")
- elseif choose == 2 then
- term.write("Programs")
- elseif choose == 3 then
- term.write("Shutdown")
- elseif choose == 4 then
- term.write("Uninstall")
- else
- end
- end
- --UI
- term.clear()
- local function drawFrontend()
- printCentred(math.floor(h/2) - 3, "")
- printCentred(math.floor(h/2) - 2, "Menu")
- printCentred(math.floor(h/2) - 1, "")
- printCentred(math.floor(h/2) + 0, ((choose == 1) and "[ Command ]") or "Command")
- printCentred(math.floor(h/2) + 1, ((choose == 2) and "[ Promgrams ]") or "Programs"
- printCentred(math.floor(h/2) + 2, ((choose == 3) and "[ Shutdown ]") or "Shutdown"
- printCentred(math.floor(h/2) + 3, ((choose == 4) and "[ Uninstall ]") or "Unsinstall"
- printCentred(math.floor(h/2) + 4, "")
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 17 or key == 200 then
- if choose > 1 then
- choose = choose - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 31 or key == 208 then
- if choose < 4 then
- choose = choose +1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- endterm.clear()
- --Events
- if choose == 1 then
- shell.run("ros/.command")
- elseif choose == 2 then
- shell.rn("ros/.programs")
- elseif choose == 3 then
- shell.run("shutdown")
- else
- shell.run("ris/.uninstall")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement