Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- crash = function(reason)
- if type(reason) ~= "string" then
- error("String excepted, got "..type(reason))
- end
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print("Something goes wrong!")
- print("Reason: "..reason)
- sleep(0.5)
- os.reboot()
- end
- runCons = function()
- shell.run("fg /sys/apps/console")
- end
- editWall = function()
- shell.run("fg edit /data/wallpaper")
- end
- local writeCentered = function(s,y)
- term.setCursorPos(math.floor((w/2)-(string.len(s)/2)),y)
- write(s)
- end
- local logonBasic = function()
- write("Username: ")
- local usr = read()
- write("Password: ")
- local pas = read("*")
- return usr,pas
- end
- logon = function()
- local logged = false
- while not logged do
- local user,pass = logonBasic()
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- paintutils.drawLine(1,1,w,1,colors.white)
- paintutils.drawLine(1,h,w,h,colors.white)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(1,2)
- if not fs.isDir("/usr/"..user) then
- printError("Invaild Username!")
- else
- local a = fs.open("/usr/"..user.."/pass","r")
- local uPass = a.readLine()
- a.close()
- if pass ~= uPass then
- printError("Invaild Password!")
- else
- logged = true
- writeCentered("Welcome!",math.floor(h/2))
- sleep(5)
- end
- end
- end
- end
- formatSize = function(size)
- if type(size) ~= "number" then
- error("Attempt to format size in "..type(size))
- end
- local format = nil
- local sizes = {
- [1] = {symbol="KB",num=1},
- [2] = {symbol="MB",num=2},
- [3] = {symbol="GB",num=3}
- }
- for i=1,#sizes do
- if i==1 then
- if size >= 1000^sizes[i].num then
- format = math.floor(size / (1000^sizes[i].num)) .. " " .. sizes[i].symbol
- end
- else
- if size >= 1000^sizes[i].num and size < 1000^sizes[i-1].num then
- format = math.floor(size / (1000^sizes[i].num)) .. " " .. sizes[i].symbol
- end
- end
- end
- if format == nil then
- format = size.." B"
- end
- return format
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement