Advertisement
Virgilcore

RobcOS Updater

Jun 9th, 2022 (edited)
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. local currentVer = "1.1.3"
  5.  
  6. local function save(table,name)
  7.  local file = fs.open(name,"w")
  8.  file.write(textutils.serialize(table))
  9.  file.close()
  10. end
  11.  
  12. local function load(name)
  13.  local file = fs.open(name,"r")
  14.  local data = file.readAll()
  15.  file.close()
  16.  return textutils.unserialize(data)
  17. end
  18.  
  19. function LoadVers()
  20.  local config = load("RobcOS_ticket")
  21.    while true do
  22.     if config == nil then
  23.         return "unknown"
  24.     elseif #config < 3 then
  25.         return "old"
  26.     else
  27.         return config[3]
  28.    end
  29.  end
  30. end
  31.    
  32. local function Update()
  33.     fs.delete("RobcOS")
  34.     shell.run("pastebin", "get", "DHuY3Uzi", "RobcOS")
  35.     shell.run("pastebin", "get", "sBSdhnyz", "codes")
  36.     fs.delete("login")
  37.     shell.run("pastebin", "get", "yYq8KmeY", "login")
  38.     fs.delete("setup")
  39.     shell.run("pastebin", "get", "FwBCLcPA", "setup")
  40.     fs.delete("startup")
  41.     shell.run("pastebin", "get", "XkSbSXYL", "startup")
  42.     shell.run("pastebin", "get", "GZZEJeCT", "termlink")
  43.     shell.run("pastebin", "get", "sMbj2VXL", "TextEdit")
  44.     shell.run("pastebin", "get", "5YWfPd8Z", "surface")
  45.     shell.run("pastebin", "get", "86rLt5Yn", "filebrowse")
  46.     shell.run("pastebin", "run", "HnUEXVKt")
  47.     os.sleep(1)
  48. end
  49.  
  50.  
  51. function UpdateChecker()
  52.     while true do
  53.     if LoadVers() == currentVer then
  54.         term.write("Up to date.")
  55.         os.sleep(1)
  56.         shell.run("RobcOS")
  57.         break
  58.     else
  59.         term.write("Downloading Update...")
  60.         local ticket = load("RobcOS_ticket")
  61.         table.insert(ticket, 3, currentVer)
  62.         save(ticket, "RobcOS_ticket")
  63.         Update()
  64.         term.clear()
  65.         term.setCursorPos(1,1)
  66.         shell.run("RobcOS")
  67.         break
  68.     end
  69.  end
  70. end
  71.  
  72.    
  73.  
  74. UpdateChecker()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement