Advertisement
SpaceRanger4321

Startup OS

Dec 31st, 2019
1,957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.45 KB | None | 0 0
  1. shell.exit()
  2. shell.run( "set shell.allow_disk_startup false" )
  3. local version = "1.7"
  4. function clr() return term.clear() end
  5. function cp(x,y) return term.setCursorPos(x,y) end
  6. function setText(col) return term.setTextColor(colors[col]) end
  7. function setBack(col) return term.setBackgroundColor(colors[col]) end
  8. function notnil(vari) if vari == nil then return false else return true end end
  9. --[[
  10.  
  11. Startup file created by SpaceRanger4827
  12. GUI Created by Just Does Games on Discord
  13.  
  14. Dev notes:
  15. - [1357Coder] Added Security no Disk Booting at top of code
  16. - [1357Coder] Updated Code + Added Auto Update
  17. ]]
  18.  
  19. if shell.getRunningProgram() ~= "startup" or shell.getRunningProgram() ~= "startup.lua" then
  20.     -- This is not startup and means that this is the installer? nope
  21. end
  22.  
  23. function printCentered(Text, Line)
  24.     local x, y = term.getSize()
  25.     x = x/2 - #Text/2
  26.     term.setCursorPos(x, Line)
  27.     if Color then
  28.         col.set(Color, BkgColor)
  29.     end
  30.     term.write(Text)
  31.     return true  
  32. end
  33.  
  34. function boot()
  35.     os.pullEvent = os.pullEventRaw
  36.     term.setBackgroundColor(colors.blue)
  37.     term.clear()
  38.     term.setCursorPos(14, 6)
  39.     term.setTextColor(colors.red)
  40.     write("Error » ")
  41.     write("No Boot Image")
  42.     sleep(1000)
  43.     os.reboot()
  44. end
  45.  
  46. if not fs.exists("/.os/.boot") then
  47.     boot()
  48. end
  49. local boot = paintutils.loadImage("/.os/.boot") -- IF THIS FILE DOES NOT EXISTS, THE PROGRAM WILL CRASH WHEN CALLING THIS VARIABLE
  50. local w,h = term.getSize()
  51.  
  52.  
  53.  -- imported from .gui
  54. title = "SpaceOS" -- imported by JDG (feel free to change this to the actual os name... was not given an os name, just assumed. lol SOS)
  55.  
  56. function main()
  57.     setText("white")
  58.     setBack("yellow")
  59.     clr()
  60.     cp(w-string.len(version),h) write(version)
  61.     cp(1,h) write(title)
  62.     for i=1, #boot do
  63.         paintutils.drawImage(boot, w/3, 4)
  64.         setBack("yellow")
  65.         for ii=1, #boot-i do
  66.             cp(2,#boot+4-ii)
  67.             term.clearLine()
  68.         end
  69.         sleep(.1)
  70.     end
  71.     sleep(1)
  72.     cp(w/3+1,2) setBack("lightGray") for i=1, 12 do write(" ") end
  73.     for i=1, math.random(1,2) do
  74.         cp(w/3+1,2)
  75.         setBack("gray")
  76.         for i=1, 12 do write(" ") sleep(.1) end
  77.         cp(w/3+1,2)
  78.         setBack("lightGray")
  79.         for i=1, 12 do write(" ") sleep(.1) end
  80.     end
  81.     setBack("yellow") clr() sleep(.5)
  82. end
  83.  
  84. local latestVersion = http.get("http://www.pastebin.com/raw/7TEJpdaK")
  85. local lversion = latestVersion.readAll()
  86. if lversion > version then
  87.     term.setBackgroundColor( colors.red )
  88.     term.clear()
  89.     printCentered("Update SpaceOS", 7)
  90.     term.setCursorPos(20, 8)
  91.     sleep(3)
  92.     term.clear()
  93.     a = read()
  94.     if a == "" then
  95.         shell.run("pastebin run LqKwPb6N")
  96.     else
  97.         shell.run("/.os/.password")
  98.     end
  99.     else
  100.         shell.run("/.os/.password")
  101. end
  102. if not ok then
  103.     setBack("yellow") setText("white") clr()
  104.   setBack("gray") cp(1,h/2-4) term.clearLine() cp(1,h/2-4)
  105.   print("Yellow screen of Death") setText("yellow")
  106.   setBack("white")
  107.   cp(1,h/2-3)
  108.   for i=1, w do
  109.     write(" ")
  110.   end
  111.   setBack("lightGray")
  112.   for i=1, 8 do
  113.     cp(1,h/2-3+i)
  114.     term.clearLine()
  115.   end
  116.   cp(1,h/2-2)
  117.   print("A yellow screen error (also called a stop error) can occur if a problem causes your device to shut down or restart unexpectedly. Your device ran into a problem and needs to restart.")
  118.   print("")
  119.   write("Error Code: ")
  120.   printError(err)
  121.   term.setCursorBlink(false)
  122.   sleep(1)
  123.   print("")
  124.   print("Press any key to reboot...")
  125.   os.pullEvent("key")
  126. else
  127.     print("Exited without Errors")
  128. end
  129. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement