Frekvens1

[CC] Local downloader

Feb 9th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. --This is intended for private use with ComputerCraft computers.
  2.  
  3. -- pastebin get wgXrQK9E pip
  4.  
  5. IP = ""
  6. port = ""
  7.  
  8. function download(file, path)
  9.  
  10.     local http = http.get("http://"..IP..":"..port.."/ComputerCraft/"..file..".txt") --Get contents of page
  11.     content = (http.readAll()) --Read and print contents of page
  12.     http.close() --Just in case
  13.    
  14.     local file = fs.open(path,"w")
  15.     file.write(content)
  16.     file.close()
  17.  
  18.    
  19. end
  20.  
  21. args = {...}
  22. fs.makeDir("downloads")
  23.  
  24. if (#args < 1) then
  25.     print("update, install")
  26. elseif args[1] == "update" then
  27.     download("pip", "pip")
  28.     print("Updated pip console!")
  29. elseif args[1] == "install" then
  30.     if (#args < 2) then
  31.         print("Please specify filename")
  32.     else
  33.         download(args[2], "downloads/"..args[2])
  34.         print("Downloaded file '"..args[2].."'!")
  35.     end
  36. end
Add Comment
Please, Sign In to add comment