Advertisement
Marlingaming

System_Boot.lua

Jun 14th, 2023 (edited)
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. --this script runs at start, ensures handbook is setup, and if not, will prompt user to run setup on external device
  2.  
  3. local Req_Files = {}
  4.  
  5. local Boot_Operation = {}
  6.  
  7. --Initial Setup Addresses
  8. local Settings_File = nil
  9. local Start_File = nil
  10. local Update_Folder = nil
  11. --Boot Run
  12. local function Complete()
  13.     local BOS = fs.open("bootlist.sys","r")
  14.     Boot_Operation = textutils.unserialize(BOS.readAll())
  15.     BOS.close()
  16.     for i = 1, #Boot_Operation do
  17.         shell.run(Boot_Operation[i],"boot")
  18.     end
  19.     local CheckUpdate = fs.find("rom/*/UpdateDetails.txt")
  20.     if CheckUpdate ~= nil then Update_Folder = fs.getDir(CheckUpdate) end
  21.    local CheckSettings = fs.find("rom/*/SystemSettings.txt")
  22.     if CheckSettings ~= nil then Settings_File = CheckSettings end
  23.     Start_File = fs.find("rom/*/System1.lua")
  24.     local file = fs.open("bootresults.sys","w")
  25.     file.write(textutile.serialize({{"Settings",Settings_File},{"Update",Update_Folder},{"Start",Start_File},{"Required",Req_Files}})
  26.     file.close()
  27.     shell.run(Start_File,"Boot")
  28. end
  29.  
  30. local function ErrorPrompt(text)
  31.     local w, h = term.getSize()
  32.     term.setBackgroundColor(colors.black)
  33.     term.clear()
  34.     term.setCursorPos(w/2 - text:len()/2, h/2)
  35.     term.write(text)
  36.     os.sleep(30)
  37.     os.shutdown()
  38. end
  39.  
  40. local function CheckFiles()
  41.     Missing = {}
  42.     for i = 1, #Req_Files do
  43.         if fs.exists(Req_Files[i]) then else Missing[#Missing + 1] = Req_File[i] end
  44.     end
  45.     Text = "Missing: \n"
  46.     for i = 1, #Missing do
  47.         Text = Text+Missing[i]+"\n"
  48.     end
  49.     if #Missing > 0 then ErrorPrompt(Text) else Complete() end
  50. end
  51.  
  52. local function CheckDir()
  53.     local i = 1
  54.     local Line = nil
  55.     local DIR = fs.open("System_Dir.txt","r")
  56.     repeat Line = DIR.readLine() if Line ~= nil then Req_Files[i] = DIR.readLine() i = i + 1 end until Line == nil
  57.     DIR.close()
  58.     CheckFiles()
  59. end
  60.  
  61. local function IntialStart()
  62.     term.setBackgroundColor(colors.black)
  63.     term.clear()
  64.     term.setCursorPos(1,1)
  65.     if fs.exist("System_Dir.txt") then CheckDir() else ErrorPrompt("missing directionary") end
  66. end
  67.  
  68. IntialStart()
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement