Advertisement
toxicfrazzles

Turtle Swarm Updater

Feb 10th, 2021 (edited)
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. --------------------------------------------
  2. --------------------------------------------
  3. -- Update script to grab latest code from --
  4. -- gitlab repo for turtle swarm.          --
  5. -- save this as startup.lua on turtle     --
  6. --------------------------------------------
  7. --------------------------------------------
  8.  
  9. -- Functions
  10. function download(url, destinationFile)
  11.     print("Downloading " .. destinationFile)
  12.     local request = http.get(url)
  13.     if request then
  14.         local data = request.readAll()
  15.         local file = fs.open(destinationFile, "w")
  16.         file.write(data)
  17.         file.close()
  18.         request.close()
  19.     else
  20.         print("Could not download file")
  21.     end
  22. end
  23.  
  24.  
  25.  
  26. -- Delete old files that might update
  27. shell.run("rm drone")
  28. shell.run("rm turtle2")
  29.  
  30. -- Make sure we have the static libs installed
  31. shell.run("pastebin get 4nRg9CHU json")
  32.  
  33. -- Download the new files from gitlab
  34. download("https://git.blokegaming.com/bloke-gaming/public/turtle-swarm/-/raw/master/drone_code/drone.lua", "drone")
  35. download("https://git.blokegaming.com/bloke-gaming/public/turtle-swarm/-/raw/master/drone_code/turtle2.lua", "turtle2")
  36.  
  37. -- Start the drone code
  38. print("Starting...")
  39. local result = shell.run("drone")
  40. if result then
  41.     print("Done")
  42. else
  43.     print("Error")
  44. end
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement