Advertisement
Le_JuiceBOX

ComputerCraft_Installer_Bore

Feb 8th, 2021 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.80 KB | None | 0 0
  1. SEPERATOR = "======================================="
  2.  
  3. --////////////////////////////////////////////////////////////////////////////////////////////////////
  4. --// Configuration
  5. --////////////////////////////////////////////////////////////////////////////////////////////////////
  6.  
  7. -- fileName, pastebinId, runOnCloud
  8. local FILES = {
  9.     {"boreBlacklist.lua",'3dbkNt7w',false},
  10.     {"borev1.lua",'3PTsm5H1',true},
  11.     {"borev2.lua",'7h9kZ1ZM',true},
  12.     {"borev2-1.lua","VdYprGR1",true},
  13.     {"floor.lua","nMxM1syd",true},
  14.     {"lavaRefuel.lua","nFSUKiYE",false},
  15.     {"update.lua",'jR4Xr7K0',true},
  16. }
  17.  
  18. list = ""
  19. for i,v in pairs(FILES) do list = list..v[1]:gsub(".lua",""); if i ~= #FILES then list = list..", "; end end
  20.  
  21. local STARTUP = [[
  22.     shell.run("clear")
  23.     print("Programs: ]]..list..[[\n\n")
  24.     print("To change blacklist, use cmd \"set bore.blacklist [PASTEID]\".\n]]..SEPERATOR..[[")
  25. ]]
  26.  
  27.  
  28. local installer = {}
  29.  
  30. --////////////////////////////////////////////////////////////////////////////////////////////////////
  31. --// Initialization
  32. --////////////////////////////////////////////////////////////////////////////////////////////////////
  33.  
  34. function run(cmd) shell.run(cmd); end
  35. run("clear")
  36.  
  37. --////////////////////////////////////////////////////////////////////////////////////////////////////
  38. --// Functions
  39. --////////////////////////////////////////////////////////////////////////////////////////////////////
  40.  
  41. function Install()
  42.     --// Verify choice
  43.     print("Installing Mining Turtle software. Proceed?")
  44.     local res = io.read()
  45.     if string.lower(res) ~= "y" then return; end
  46.     run("clear")
  47.     --// Download files
  48.     print("Downloading files...")
  49.     for _,dat in pairs(FILES) do
  50.         --shell.run("delete "..dat[1])
  51.         if dat[3] then
  52.             newPastebinFile(dat[1],dat[2])
  53.         else
  54.             downloadPaste(dat[1],dat[2])
  55.         end
  56.         print(dat[1].." installed...")
  57.         sleep(0.5)
  58.     end
  59.     --// Make startup file
  60.     makeStartup(STARTUP)
  61.     --// Restart
  62.     print("\n\nFinished.")
  63.     sleep(1)
  64.     run("clear")
  65.     run("reboot")
  66. end
  67.  
  68.  
  69. --////////////////////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. function downloadPaste(name,id) -- old
  72.     if fs.exists(name) then shell.run("delete "..name); end
  73.     shell.run("pastebin get "..id.." "..name)
  74. end
  75.  
  76. function makeStartup(str,paste) -- new
  77.     if fs.exists("startup.lua") then shell.run("delete startup.lua"); end
  78.     if paste then shell.run("pastebin get "..paste.." startup"); return; end
  79.     local file = fs.open("startup.lua","w")
  80.     file.write(str)
  81.     file.close()
  82. end
  83.  
  84. function newPastebinFile(name, id)
  85.     if fs.exists(name) then shell.run("delete "..name); end
  86.     local file = fs.open(name,"w")
  87.     file.write("shell.run(\"pastebin run "..id.."\")")
  88.     file.close()
  89. end
  90.  
  91.  
  92. Install();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement