zahar0401

Orbital Startup

Sep 7th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. if not term.isColor() then
  2.  error("LEFI cannot run on non-advanced computers.")
  3. end
  4.  
  5. -- Declare extended Lua attributes
  6.  
  7. rawset(_G, "__declare", function(g, v)
  8.  return rawset(_G, g, v)
  9. end)
  10.  
  11. __declare("__declare_api", function(a, g, v)
  12.  return rawset(_G[a], g, v)
  13. end)
  14.  
  15. __declare("__try", function(f, e)
  16. local r = {pcall(f)}
  17. if table.remove(r, 1) == true then
  18.  return unpack(r)
  19. else
  20.  if e ~= nil then
  21.   e(unpack(r))
  22.  else
  23.   return __kstop(0x0000FFFF, unpack(r))
  24.  end
  25. end
  26. end)
  27.  
  28. __declare("__kstruct", function(t)
  29.  if t == _G then
  30.   return setmetatable({}, {
  31.    __index = t,
  32.    __newindex = function(table, key, value)
  33.     __kstop(0x00000004, table, key, value)
  34.    end,
  35.    __metatable = {}
  36.   })
  37.  else
  38.   return setmetatable({}, {
  39.    __index = t,
  40.    __newindex = function(table, key, value)
  41.     __kstop(0x00000005, table, key, value)
  42.    end,
  43.    __metatable = {}
  44.   })
  45.  end
  46. end)
  47.  
  48. -- declare library persistence loader
  49. __declare("persist", function(n, c)
  50.  local h = fs.open("/tmp/"..n, "w")
  51.  h.writeLine(c)
  52.  h.close()
  53.  os.loadAPI("/tmp/"..n)
  54.  fs.delete("/tmp/"..n)
  55. end)
  56.  
  57. __declare("drawBootManager", function(opt)
  58.     term.setBackgroundColor(colors.black)
  59.     term.clear()
  60.     term.setCursorPos(1,1)
  61.     if not opt then
  62.         boot_printColoredTextLine(2, "             Orbital Boot Manager v1.0             ", colors.lightGray, colors.black)
  63.         boot_printColoredTextLine(18, " F2=ESI Setup                        F10=Boot Menu ", colors.lightGray, colors.black)
  64.     else
  65.         boot_printColoredTextLine(2, "             Orbital Boot Manager v2.1             ", colors.red, colors.black)
  66.         boot_printColoredTextLine(18, " CTRL+R=Reboot                                     ", colors.red, colors.black)
  67.     end
  68. end)
  69.  
  70. local sr = shell.run
  71.  
  72. if not fs.isDir("/boot") or not loadfile("/boot/esi/esiboot.b") then
  73.     drawBootManager(true)
  74.     term.setBackgroundColor(colors.black)
  75.     term.setTextColor(colors.red)  
  76.     term.setCursorPos(2,4)
  77.     print("The Orbital Boot Manager was unable to boot the")
  78.     term.setCursorPos(2,5)
  79.     print("operating system.")
  80.     term.setCursorPos(2,7)
  81.     print("Status:")
  82.     term.setCursorPos(2,8)
  83.     print("ESI_BINARIES_INVALID (0x00000002)")
  84.     term.setCursorPos(2,10)
  85.     print("Information:")
  86.     term.setCursorPos(2,11)
  87.     print("One or more ESI files are missing.")
  88.     term.setCursorPos(2,12)
  89.     print("Please re-install the operating system.")
  90.     while true do
  91.         sleep(1)
  92.     end
  93. end
  94.  
  95. sr("/boot/esi/esiboot.b")
Advertisement
Add Comment
Please, Sign In to add comment