Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- --Print Centered
- function printCentered(y,s)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- --Draw Menu Function
- local nOption = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Notre premier OS")
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Commandes")
- elseif nOption == 2 then
- term.write('Programmes')
- elseif nOption == 3 then
- term.write("Enteindre")
- elseif nOption == 4 then
- term.write('Desinstaller')
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered(math.floor(h/2) - 3, "")
- printCentered(math.floor(h/2) - 2, "Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOption == 1) and "[ Commandes ]") or "Commandes")
- printCentered(math.floor(h/2) + 1, ((nOption == 2) and "[ Programmes ]") or "Programmes")
- printCentered(math.floor(h/2) + 2, ((nOption == 3) and "[ Eteindre ]") or "Eteindre")
- printCentered(math.floor(h/2) + 3, ((nOption == 4) and "[ Desinstaller ]") or "Desinstaller")
- 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 nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 31 or key == 208 then
- if nOption < 4 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- term.setCursorPos(1,1)
- print("Tapez votre commande")
- input = read()
- shell.run(input)
- print("Programme termine :(")
- sleep(3)
- shell.run(".menu")
- elseif nOption == 2 then
- shell.run("programs")
- print("Appuyez sur un entrer pour continuer")
- input = read()
- shell.run(".menu")
- elseif nOption == 3 then
- os.shutdown()
- else
- shell.run("os.unistall")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement