Advertisement
Marlingaming

CCSPS IRON - 2.5.0 - Update Handler

Jun 14th, 2023 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. local Paster = settings.get("paster")
  2. shell.run(Paster,"get", "cJJU1pDZ","os/System/TempFiles/Versions.txt")
  3. local file = fs.open("os/System/TempFiles/Versions.txt","r")
  4. local List = textutils.unserialize(file.readAll())
  5. file.close()
  6. local Version = settings.get("version")
  7. local Details = fs.open(fs.complete("os/Updater/StoredVersions",Version),"r")
  8. local Stamp = Details.readLine()
  9. Details.close()
  10. local Update = false
  11. for i = 1, #List do
  12. if List[i][2] > Stamp then Update = true end
  13. end
  14.  
  15. function UpdateMenu()
  16. local New = {}
  17. for i = 1, #List do
  18. if List[i][2] > Stamp then New[#New+1] = i end
  19. end
  20. New[#New + 1] = "Cancel"
  21. term.clear()
  22. term.setCursorPos(1,1)
  23. print("current Version: "..Version)
  24. print("New Versions:")
  25. local n = 1
  26. while true do
  27. for i = 1, #New do
  28. term.setCursorPos(1,i + 2)
  29. term.clearLine()
  30. if n == i then term.write(">> "..i.." - "..List[New[i]][1]) else term.write(" "..i.." - "..List[New[i]][1]) end
  31. end
  32. local a, b = os.pullEvent("key")
  33. if b == keys.w then if n == 0 then n = #New else n = n - 1 end end
  34. if b == keys.s then if n == #New then n = 1 else n = n + 1 end end
  35. if b == keys.enter then break end
  36.  
  37. end
  38. if n == #New then else shell.run("os/Updater/Installer.lua",List[New[n]][3]) end
  39. end
  40.  
  41. function Prompt()
  42. term.clear()
  43. term.setCursorPos(1,1)
  44. print("Update Detected, Install?")
  45. print("y/n")
  46. local a, b
  47. repeat
  48. a, b = os.pullEvent("key")
  49. until b == keys.y or b == keys.n
  50. if b == keys.y then UpdateMenu() end
  51. end
  52.  
  53. if Update == true then Prompt() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement