-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.lua
66 lines (59 loc) · 2.06 KB
/
startup.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--[[
NanaLauncher - Project "NanaOS"
The Updater(WIP) and something
Copyright 2023 K-Nana
License: MIT License https://opensource.org/license/mit/
]]
assert(term.isColour(), "NanaOS cannot be used on monochrome computers because it uses features such as color, click detection, and multishell that are only available on advanced computers.")
local nana = true
function drawText(x,y,text,tcl,bgcl)
if tcl then term.setTextColor(tcl) end
if bgcl then term.setBackgroundColor(bgcl) end
term.setCursorPos(x,y)
term.write(text)
end
function craftOS()
while true do
local e, k = os.pullEvent("key")
if k == keys.enter then
term.setTextColor(colors.yellow)
print(os.version())
nana = false
return
end
end
end
term.clear()
term.setTextColor(colors.purple)
term.setCursorPos(1,1)
term.write("Nana")
term.setTextColor(colors.magenta)
print("Launcher")
term.setTextColor(colors.white)
print(os.version()..", ".._VERSION)
print("Press Enter to Go to CraftOS (Debug Shell)")
parallel.waitForAny(craftOS, function() os.sleep(2) end)
if nana then
if http then
print("Checking Updates...")
local newUpdate = assert(load("return "..http.get("https://raw.githubusercontent.com/k-7iro/NanaOS/main/update.nana").readAll()))()
local newVerdata = newUpdate["Files"]
local newName = newUpdate["VersionName"]
settings.load("update.nana")
local oldVerdata = settings.get("Files")
for file, hash in pairs(newVerdata) do
if hash ~= oldVerdata[file] then
print("Updating "..file.." ...")
local fh = fs.open(file, "w")
fh.write(http.get("https://raw.githubusercontent.com/k-7iro/NanaOS/main/"..file).readAll())
fh.close()
end
end
if newVerdata ~= oldVerdata then
settings.set("Files", newVerdata)
settings.set("VersionName", newName)
settings.save("update.nana")
end
end
shell.run("os/login.lua")
end