Advertisement
Guest User

apiload,lua

a guest
Feb 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. local Apis = {
  2.   [1]={name="OS Utils",path="/sys/apis/osutils"},
  3.   [2]={name="OS Power API",path="/sys/apis/ospower"}
  4. }
  5. local w,h = term.getSize()
  6. local function redrawLogonMenu()
  7.   term.setBackgroundColor(colors.blue)
  8.   term.setTextColor(colors.white)
  9.   term.clear()
  10.   term.setCursorPos(1, 1)
  11.   paintutils.drawLine(1,1,w,1,colors.white)
  12.   paintutils.drawLine(1,h,w,h,colors.white)
  13.   term.setBackgroundColor(colors.blue)
  14.   term.setTextColor(colors.white)
  15.   term.setCursorPos(1,2)
  16. end
  17. local path = shell.path()
  18. shell.setPath(path..":/sys/apps")
  19. for i=1,#Apis do
  20.   print("Loading "..Apis[i].name)
  21.   local loaded = os.loadAPI(Apis[i].path)
  22.   local err = false
  23.   if not fs.exists(Apis[i].path) then
  24.     printError(Apis[i].path.." is missing!")
  25.     err = true
  26.   elseif not loaded then
  27.     printError(Apis[i].path.." is corrupt!")
  28.     err = true
  29.   end
  30.   if err then
  31.     os.pullEvent("key")
  32.     os.reboot()
  33.   else
  34.     print("Loaded "..Apis[i].name)
  35.   end
  36. end
  37. sleep(2)
  38. redrawLogonMenu()
  39. shell.run("/sys/oslogon")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement