Advertisement
posLop

up

Jul 2nd, 2021 (edited)
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. term.write("Would you like to download the code or the updater? \n code or up")
  4. local mode = term.read()
  5.  
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. term.write("Which program would you like to use? \n Farm \n Quarry \n Furnace \n")
  9. local program = term.read()
  10. term.clear()
  11. term.setCursorPos(1,1)
  12.  
  13. if mode == "code" then
  14. local FILENAME = '/'..program..'.lua'
  15. local cacheBreak = tostring(math.random(0, 99999))
  16.  
  17. if program == "farm" then
  18. res, err = http.get('https://gist.githubusercontent.com/posLop/88141bcd6989689d5eb12d33287bc287/raw/carrot.lua?breaker=' .. cacheBreak)
  19.  
  20. elseif program == "quarry" then
  21. res, err = http.get('https://gist.githubusercontent.com/posLop/5902d8ff5154abeef01221faae3f061e/raw/quarry.lua?breaker=' .. cacheBreak)
  22.  
  23. elseif program == "furnace" then
  24. res, err = http.get('https://gist.githubusercontent.com/posLop/79a81458ae396e5c3b464a01349df60f/raw/funnel.lua?breaker=' .. cacheBreak)
  25.  
  26. else
  27. term.write("invalid name")
  28. return
  29. end
  30.  
  31. if not res then error(err) end
  32.  
  33. local code = res.readAll()
  34.  
  35. if not(fs.exists(FILENAME))
  36. then
  37. local newHarvest = fs.open(FILENAME, 'w')
  38. newHarvest.close()
  39. end
  40.  
  41. local readFile = fs.open(FILENAME, 'r')
  42. local oldCode = readFile.readAll()
  43. readFile.close()
  44.  
  45. local file = fs.open(FILENAME, 'w')
  46.  
  47. if oldCode == code
  48. then
  49. file.write(oldCode)
  50. print('NO CHANGES MADE - Same Code')
  51. else
  52. file.write(code)
  53. print('WRITING UPDATE')
  54. byteDiff = string.len(code) - string.len(oldCode)
  55.  
  56. if byteDiff >= 0
  57. then
  58. print(tostring(math.abs(byteDiff)) .. ' bytes added')
  59. else
  60. print(tostring(math.abs(byteDiff)) .. ' bytes removed')
  61. end
  62. end
  63. file.close()
  64. res.close()
  65.  
  66. elseif mode == "up" then
  67. if program == "quarry" then
  68. shell.run("pastebin", "get", "RxebTRQQ", "quarryUp")
  69.  
  70. elseif program == "farm" then
  71. shell.run("pastebin", "get", "vPjt5XQ8", "farmUp")
  72.  
  73. elseif program == "furnace" then
  74. shell.run("pastebin", "get", "5s1uvhv4", "furnaceUp")
  75. else
  76. term.write("invalid name")
  77. end
  78. else
  79. term.write("invalid name")
  80. end
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement