Marlingaming

CC Tweaked CCSPS Iron - Online Version Check - Update

Jan 28th, 2022 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. settings.load(".settings")
  2. local ClientVersion = settings.get("ClientVersion")
  3. local NetVersion = "2.0.0"
  4. local AllowUpdate = true
  5.  
  6. local ReplaceItems = {}
  7. local AddItems = {}
  8. local AddClientApps = {}
  9. local RemoveItems = {}
  10. local Run = {"BCCRGYMR"}
  11.  
  12.  
  13. local function Clear()
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. end
  17.  
  18. function Prompt()
  19. print("Updates found")
  20. print("do you wish to update system?")
  21. print("current version = ",ClientVersion)
  22. print("latest version = ",NetVersion)
  23. print("updates System to latest OS")
  24. print("y/n")
  25. local event
  26. repeat
  27. event = {os.pullEvent("key")}
  28. until event[2] == keys.y or event[2] == keys.n
  29. if event[2] == keys.n then
  30. os.sleep(1)
  31. elseif event[2] == keys.y then
  32. UpdateSystemStart()
  33. end
  34. end
  35.  
  36. function UpdateSystemStart()
  37. Clear()
  38. print("Starting Update..")
  39. print("deleting Items")
  40. for i = 1, #RemoveItems do
  41. fs.delete(RemoveItems[i])
  42. print(RemoveItems[i]," removed")
  43. end
  44. print("Replacing Items")
  45. for i = 1, #ReplaceItems do
  46. fs.delete(ReplaceItems[i][1])
  47. shell.run( settings.get("osPaster"),"get",ReplaceItems[i][2],ReplaceItems[i][1])
  48. print(ReplaceItems[i][1]," replaced")
  49. end
  50. print("Installing New Items")
  51. for i = 1, #AddItems do
  52. if fs.exists(AddItems[i][1]) then
  53.  
  54. else
  55.  
  56. shell.run( settings.get("osPaster"),"get",AddItems[i][2],AddItems[i][1])
  57. print(AddItems[i][1]," installed")
  58. end
  59. end
  60. print("Base Update Complete")
  61. print("Downloading New Apps")
  62. for i = 1, #AddClientApps do
  63. if fs.exists(AddClientApps[i][2]) then
  64.  
  65. else
  66. shell.run( "os/System/Programs/InstallManager", AddClientApps[i][2], AddClientApps[i][3],"Client", AddClientApps[i][1],"blank")
  67. end
  68. end
  69. for i = 1, #Run do
  70. shell.run(settings.get("osPaster"),"run",Run[i])
  71. end
  72. print("Installing Files")
  73. print("UpdateComplete")
  74. UpdateSystemEnd()
  75. end
  76.  
  77. function UpdateSystemEnd()
  78. settings.set("ClientVersion",NetVersion)
  79. settings.save(".settings")
  80. print("Rebooting..")
  81. os.sleep(2)
  82. shell.run(settings.get("PowerManager"),"restart")
  83. end
  84.  
  85. if ClientVersion ~= NetVersion and AllowUpdate == true then
  86. Prompt()
  87. else
  88.  
  89. end
Add Comment
Please, Sign In to add comment