sPhone/src/sPhone.lua

86 lines
1.4 KiB
Lua
Raw Normal View History

2015-07-31 19:59:52 +02:00
local function crash(err)
2015-07-31 19:52:45 +02:00
os.pullEvent = os.pullEventRaw
if not err then
err = "Unknown"
end
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,2)
term.setTextColor(colors.white)
2015-07-31 20:01:49 +02:00
print(" ###")
print(" # ")
print(" ###")
print(" #")
print(" ###")
2015-07-31 19:52:45 +02:00
print("")
print("sPhone crash: ")
print(err)
while true do
sleep(3600)
end
end
2015-07-31 20:27:52 +02:00
local function kernel()
_G.sPhone = {
version = "1.0",
eApp = false,
}
if not fs.exists("/.sPhone/apis") then
fs.makeDir("/.sPhone/apis")
end
for k, v in ipairs(fs.list("/.sPhone/apis")) do
os.loadAPI("/.sPhone/apis/"..v)
end
function os.version()
return "sPhone "..sPhone.version
end
2015-07-31 19:52:45 +02:00
2015-07-31 20:27:52 +02:00
local function clear()
term.setBackgroundColor(colors.white)
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.black)
end
os.forceShutdown = os.shutdown
os.forceReboot = os.reboot
function os.shutdown()
clear()
print("Goodbye")
sleep(1)
os.forceShutdown()
end
function os.reboot()
clear()
print("See you!")
sleep(1)
os.forceReboot()
end
2015-07-31 22:00:19 +02:00
function home()
while true do
clear()
local reboot = gui.pulseButton({2, 3}, {colors.lime, colors.green}, "Reboot", os.reboot())
gui.render({reboot})
end
end
function login()
end
2015-07-31 22:01:20 +02:00
home()
2015-07-31 19:52:45 +02:00
end
local ok, err = pcall(kernel)
if not ok then
sPhone.crash(err)
end