mirevall

CustomBiosStart

Apr 2nd, 2017 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. function yN()
  2. local n=1
  3. while true do
  4. local x, y=term.getCursorPos()
  5. term.clearLine()
  6. if n==1 then write(">No< Yes") else write (" No >Yes<") end
  7. term.setCursorPos(x, y)
  8. a, b=os.pullEvent("key")
  9. if b==263 and n==2 then n=1 end
  10. if b==262 and n==1 then n=2 end
  11. if b==257 then
  12. print("")
  13. if n==1 then return true end
  14. if n==2 then return false end
  15. end
  16. end
  17. end
  18.  
  19. if fs.exists("/CB/CustomBiosUpdate") then
  20. shell.run("delete /CB/CustomBiosUpdate")
  21. end
  22.  
  23. term.setTextColour(colours.green)
  24. print ("Checking for Update")
  25. if not fs.exists("/CB/Beta") then
  26. term.setTextColour(colours.yellow)
  27. local beta = fs.open("/CB/Beta", "w")
  28. print("Do you want to use BETAs ?")
  29. if yN() == false then
  30. beta.write("true")
  31. else
  32. beta.write("false")
  33. end
  34. beta.close()
  35. end
  36. term.setTextColour(colours.white)
  37.  
  38.  
  39. local beta = fs.open("/CB/Beta", "r")
  40. if beta[0] == "false" then
  41. shell.run("pastebin get wccYFDn4 /CB/CustomBiosUpdate")
  42. else
  43. shell.run("pastebin get ccbrWFpb /CB/CustomBiosUpdate")
  44. end
  45.  
  46. term.setTextColour(colours.red)
  47. local update = fs.open("/CB/CustomBiosUpdate", "r")
  48. local curent = fs.open("/CB/Files/CustomBiosCurrent", "r")
  49.  
  50. if not fs.exists("/CB/Files/CustomBiosCurrent") or update[0] ~= curent[0] then
  51. term.setTextColour(colours.green)
  52. print("An update is available")
  53. os.sleep(0.5)
  54. print("Updating...")
  55. os.sleep(1)
  56. if fs.exists("/CB/Files/CustomBiosCurrent") then
  57. curent.close()
  58. end
  59. update.close()
  60. shell.run("delete /CB/Files/")
  61. shell.run("mkdir /CB/Files/")
  62. term.setTextColour(colours.white)
  63. if beta[0] == "false" then
  64. shell.run("pastebin get 7fzEVSp0 /CB/Files/CustomBios")
  65. else
  66. shell.run("pastebin get rMqkrB8f /CB/Files/CustomBios")
  67. end
  68. shell.run("copy /CB/CustomBiosUpdate /CB/Files/CustomBiosCurrent")
  69. term.setTextColour(colours.green)
  70. print("Updated.")
  71. os.sleep(1)
  72. else
  73. curent.close()
  74. update.close()
  75. end
  76.  
  77. shell.run("/CB/Files/CustomBios")
Add Comment
Please, Sign In to add comment