Advertisement
Guest User

Random1

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1.  
  2.  
  3. local function fetchUrl(url)
  4. local valid, err = http.checkURL(url)
  5. if not valid then
  6. error('Invalid URL: ' .. err)
  7. end
  8. local h = http.get(url)
  9. if h == nil then
  10. error('Unknown error when fetching: ' .. url)
  11. end
  12. if h.getResponseCode() ~= 200 then
  13. error('Unexpected response from server')
  14. end
  15. if redstone and not require then
  16. h.close()
  17. return rv
  18. end
  19.  
  20. local function wget(url, filename)
  21. local data = fetchUrl(url)
  22. if fs.exists(filename) then
  23. fs.delete(filename)
  24. end
  25. local h = fs.open(filename, 'w')
  26. h.write(data)
  27. h.close()
  28. end
  29.  
  30. local sourceUrl = 'https://raw.githubusercontent.com/jnordberg/minecraft-replicator/master/'
  31.  
  32. local sourceFiles = {
  33. 'bootstrap',
  34. 'lib/class.lua',
  35. 'lib/items.lua',
  36. 'lib/serpent.lua',
  37. 'lib/utils.lua',
  38. 'replicator',
  39. }
  40.  
  41. term.clear()
  42. term.setCursorPos(3, 2)
  43. term.write('Installing')
  44.  
  45. fs.makeDir('lib')
  46. fs.makeDir('state')
  47.  
  48. for i,file in ipairs(sourceFiles) do
  49. term.write('.')
  50. wget(sourceUrl .. file, file)
  51. end
  52.  
  53. shell.run('replicator')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement