Guest User

Untitled

a guest
Jan 6th, 2020
174
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local raw_loadfile = ...
  2. _G._OSVERSION = "OpenOS 1.6.1"
  3. local title = "OpenOS"
  4. local text1 = "All done!"
  5. local component = component
  6. local computer = computer
  7. local unicode = unicode
  8. local curret_screen_adress = nil
  9. local function centrize(wi, screenWidth)
  10. return math.floor(screenWidth / 2 - wi / 2)
  11. end
  12. local runlevel, shutdown = "S", computer.shutdown
  13. computer.runlevel = function() return runlevel end
  14. computer.shutdown = function(reboot)
  15. runlevel = reboot and 6 or 0
  16. if os.sleep then
  17. computer.pushSignal("shutdown")
  18. os.sleep(0.1)
  19. end
  20. shutdown(reboot)
  21. end
  22. local screen = component.list('screen', true)()
  23. for address in component.list('screen', true) do
  24. if #component.invoke(address, 'getKeyboards') > 0 then
  25. screen = address
  26. curret_screen_adress = address
  27. break
  28. end
  29. end
  30. _G.boot_screen = screen
  31. local gpu = component.list("gpu", true)()
  32. local w, h = 160, 50
  33. if gpu and screen then
  34. component.invoke(gpu, "bind", screen)
  35. w, h = component.invoke(gpu, "maxResolution")
  36. component.invoke(gpu, "setResolution", w, h)
  37. component.invoke(gpu, "setBackground", 0xd4d4d4)
  38. component.invoke(gpu, "setForeground", 0x2D2D2D)
  39. component.invoke(gpu, "fill", 1, 1, w, h, " ")
  40. component.invoke(gpu, "set", centrize(#title, w), h/2, title)
  41. component.invoke(gpu, "setForeground", 0xC3C3C3)
  42. component.invoke(gpu, "set", w/2-13,h/2+2,string.rep("─", 26))
  43. end
  44. local y = 1
  45. local function status(msg)
  46. if gpu and screen then
  47. component.invoke(gpu, "setForeground", 0x878787)
  48. if y < 20 then
  49. loa = string.rep("─", y*1.3)
  50. else
  51. y = 100
  52. loa = string.rep("─", 26)
  53. end
  54. component.invoke(gpu, "set", w/2-13,h/2+2,loa)
  55. if loa == 100 then os.sleep(1) end
  56. component.invoke(gpu, "fill",1,h,w,h," ")
  57. component.invoke(gpu, "set",1,h,"Status: "..msg)
  58. if y == 100 then
  59. component.invoke(gpu, "fill", 1, 1, w, h, " ")
  60. component.invoke(gpu, "setForeground", 0x2D2D2D)
  61. component.invoke(gpu, "set", centrize(#text1, w), h/2, text1)
  62. end
  63. y = y + 1
  64. end
  65. end
  66. status("Booting " .. _OSVERSION .. "...")
  67. local loadfile = function(file)
  68. status("> " .. file)
  69. return raw_loadfile(file)
  70. end
  71.  
  72. local function dofile(file)
  73. local program, reason = loadfile(file)
  74. if program then
  75. local result = table.pack(pcall(program))
  76. if result[1] then
  77. return table.unpack(result, 2, result.n)
  78. else
  79. error(result[2])
  80. end
  81. else
  82. error(reason)
  83. end
  84. end
  85. status("Initializing package management...")
  86. local package = dofile("/lib/package.lua")
  87. do
  88. _G.component = nil
  89. _G.computer = nil
  90. _G.process = nil
  91. _G.unicode = nil
  92. _G.package = package
  93. package.loaded.component = component
  94. package.loaded.computer = computer
  95. package.loaded.unicode = unicode
  96. package.preload["buffer"] = loadfile("/lib/buffer.lua")
  97. package.preload["filesystem"] = loadfile("/lib/filesystem.lua")
  98. _G.io = loadfile("/lib/io.lua")()
  99. package.delayed["text"] = true
  100. package.delayed["sh"] = true
  101. package.delayed["transforms"] = true
  102. package.delayed["term"] = true
  103. end
  104. status("Initializing file system...")
  105. require("filesystem").mount(computer.getBootAddress(), "/")
  106. package.preload={}
  107. status("Running boot scripts...")
  108. local function rom_invoke(method, ...)
  109. return component.invoke(computer.getBootAddress(), method, ...)
  110. end
  111. local scripts = {}
  112. for _, file in ipairs(rom_invoke("list", "boot")) do
  113. local path = "boot/" .. file
  114. if not rom_invoke("isDirectory", path) then
  115. table.insert(scripts, path)
  116. end
  117. end
  118. table.sort(scripts)
  119. for i = 1, #scripts do
  120. dofile(scripts[i])
  121. end
  122. status("Initializing components...")
  123. for c, t in component.list() do
  124. computer.pushSignal("component_added", c, t)
  125. end
  126. status("Initializing system...")
  127. computer.pushSignal("init")
  128. ev = require("event")
  129. ev.pull(1, "init")
  130. component.invoke(gpu,"setBackground", 0x000000)
  131. component.invoke(gpu,"setForeground", 0xFFFFFF)
  132. _G.runlevel = 1
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×