View difference between Paste ID: 9aG8B0VL and RpufZgYT
SHOW: | | - or go back to the newest paste.
1
if fs.exists("blueos/") == false then
2
    fs.makeDir("blueos")
3
end
4
if fs.exists("blueos/home") == false then
5
    fs.makeDir("blueos/home")
6
end
7
if fs.exists("blueos/data") == false then
8
    local file = fs.open("blueos/data","w")
9
    file.write("0")
10
    file.close()
11
end
12
local file = fs.open("blueos/data","r")
13
local startups = file.readLine()
14
file.close()
15
16
if tonumber(startups) ~= nil then
17
    local file = fs.open("blueos/data","w")
18
    file.write(tostring(startups + 1))
19
    local startups = startups + 1
20
    file.close()
21
else
22
    startups = "error"
23
end
24
term.clear()
25
term.setCursorPos(1,2)
26
term.setTextColor(colors.blue)
27
write("Blue OS")
28
local width, height = term.getSize()
29
paintutils.drawLine(1,3,width,3,colors.lightGray)
30
term.setTextColor(colors.black)
31
term.setCursorPos(1,3)
32
local motd = {
33
    [1] = "Blue OS: It's terrible!",
34
    [2] = "Why are you using this?",
35
    [3] = "Hey, got anything better to do?",
36
    [4] = "Made by MinerMan132 (god what have I done)",
37
    [5] = "Hi diddly ho neighborino!",
38
    [6] = "Color or colour?",
39
    [7] = "You've used this terrible OS "..startups.." times!",
40-
    [8] = "The BlueOS help program is simpley called \"help\""
40+
    [8] = "I'm PotatOS, but not a virus! :D"
41
    }
42
write("  ")
43
print(motd[math.random(1,#motd)])
44
print("")
45
term.setBackgroundColor(colors.black)
46
shell.setDir("blueos/home")
47
48
local function main()
49
while true do
50
    term.setTextColor(colors.blue)
51
    write(" ")
52
    if shell.dir() ~= "" then
53
        write("/")
54
    end
55
    write(shell.dir().." > ")
56
    term.setTextColor(colors.cyan)
57
    local command = read()
58
    if command ~= "uninstall" then
59
        shell.run(command)
60
    else
61
        if fs.exists(shell.dir().."/uninstall") then
62
            print("Do you want to run the program \"uninstall\", instead of uninstalling BlueOS? (y/n)")
63
            local awnser = read()
64
            if awnser == "y" or "yes" then
65
                uninstallc = true
66
            else
67
                shell.run("uninstall")
68
            end
69
        else
70
            uninstallc = true
71
        end
72
        if uninstallc == true then
73
            term.setTextColor(colors.blue)
74
            print("Are you absolutely sure you want to uninstall BlueOS?")
75
            print("This will delete ALL files you have stored under the BlueOS directory!")
76
            print("(y/n)")
77
            term.setTextColor(colors.red)
78
            local awnser = read()
79
            if awnser == "y" or awnser == "yes" then
80
                term.setTextColor(colors.blue)
81
                print("Final confirmation. Please don't. (y/n)")
82
                term.setTextColor(colors.red)
83
                local awnser = read()
84
                if awnser == "y" or awnser == "yes" then
85
					term.setTextColor(colors.lightBlue)
86
                    write("Ok, bye  ")
87
					term.setTextColor(colors.gray)
88
                    sleep(1)
89
                    write(":")
90
                    sleep(1)
91
                    write("'")
92
                    sleep(1)
93
                    write("(")
94
                    sleep(2)
95
                    term.setTextColor(colors.red)
96
                    print("")
97
                    print("Removing Directory")
98
                    fs.delete("blueos/")
99
                    print("Removing Startupfile")
100
                    fs.delete(shell.getRunningProgram())
101
					print("Done :(")
102
					sleep(2)
103
					os.reboot()
104
                else
105
                term.setTextColor(colors.lightBlue)
106
                print("Yay! Thanks! :D")
107
                uninstallc = nil
108
                end
109
            else
110
            uninstallc = nil
111
            end
112
        end
113
    end
114
end
115
end
116
117
function stop()
118
while true do
119
    local ok, msg = pcall(main)
120
    if not ok then
121
        print("")
122
        printError("Whoopsie it crashed!")
123
        printError("Error: "..msg)
124
        term.setTextColor(colors.lightBlue)
125
        term.setCursorBlink(false)
126
        
127
        print("Restarting in 5 seconds . . .")
128
        sleep(5)
129
        os.reboot()
130
    end
131
end
132
end
133
134
while true do
135
    local ok2, msg2 = pcall(stop)
136
    if not ok then
137
        term.setTextColor(colors.yellow)
138
        print("Returning to shell...")
139
        shell.setDir("")
140
        sleep(0.3)
141
        break
142
    end
143
end