View difference between Paste ID: cDwFm9CT and rm4LmAKh
SHOW: | | - or go back to the newest paste.
1
local w,h = term.getSize()
2
3
--Center Text
4
5
function printCentered (y,s)
6
    local x = math.floor((w - string.len(s)) /2)
7
    term.setCursorPos(x,y)
8
    term.clearLine()
9
    term.write(s)
10
end
11
12
--Drawmenu
13
14
local nOption = 1
15
16
local function drawMenu()
17
    term.setBackgroundColor(colors.cyan)
18
    term.clear()
19
    term.setCursorPos(1,1)
20
    local logo = paintutils.loadImage("os/.logo")
21
    paintutils.drawImage(logo, 1, 1)
22
    term.setBackgroundColor(colors.cyan)
23
    
24
    term.setCursorPos(w-11,1)
25
    if nOption == 1 then
26-
        term.write("DOS")
26+
        term.write("Reset account")
27
    elseif nOption == 2 then
28-
        term.write("EXECUTIVE")
28+
        term.write("Exit")
29-
    elseif nOption == 3 then
29+
 	else
30-
        term.write("SHUTDOWN")
30+
31-
    elseif nOption == 4 then
31+
32-
        term.write("DISK")
32+
33-
    elseif nOption == 5 then
33+
34-
        term.write("SETTINGS")
34+
35-
    else
35+
36
local function drawFrontend()
37
    printCentered(math.floor(h/2) -3, "")
38
    printCentered(math.floor(h/2) -2, "SETTINGS")
39
    printCentered(math.floor(h/2) -1, "")
40
    printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ Reset account ]") or "Reset account")
41
    printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ Exit ]") or "Exit")
42
end
43
44-
    printCentered(math.floor(h/2) -2, "START")
44+
45
46-
    printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ DOS ]") or "DOS")
46+
47-
    printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ EXECUTIVE ]") or "EXECUTIVE")
47+
48-
    printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ SHUTDOWN ]") or "SHUTDOWN")
48+
49-
    printCentered(math.floor(h/2) + 3, (nOption == 4 and "[ DISK ]") or "DISK")
49+
50-
	printCentered(math.floor(h/2) + 4, (nOption == 5 and "[ SETTINGS ]") or "SETTINGS")
50+
51
        if e == "key" then
52
            local key = p
53
            if key == keys.up or key == 200 then
54
            
55
                if nOption > 1 then
56
                    nOption = nOption -1
57
                    drawMenu()
58
                    drawFrontend()
59
                end
60
            elseif key == keys.down or key == 208 then
61
                if nOption < 2 then
62
                    nOption = nOption +1
63
                    drawMenu()
64
                    drawFrontend()
65
                end
66
        elseif key == keys.enter then
67
            break
68
end
69
end
70-
                if nOption < 5 then
70+
71
72
term.clear()
73
74
--Conditions
75
if nOption == 1 then
76
    term.clear()
77
    term.setCursorPos(1,1)
78
    print("Are you sure? Password and username will be wiped and reset! y/n")
79
    alt = read()
80
    if alt == "y" then
81
    	shell.run("os/setup")    
82
    elseif alt == "n" then
83
        print("Reset Aborted")
84
        sleep(3)
85-
    term.setBackgroundColor(colors.black)
85+
        shell.run("os/.functions")
86-
    shell.run("os/.DOS")
86+
    end
87-
elseif nOption == 2 then
87+
88-
    shell.run("os/.EXECUTIVE")
88+
	shell.run("os/.functions")
89-
elseif nOption == 3 then
89+