Advertisement
CCAppStore

HTTP Request Tool

Jul 21st, 2016
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. --sleep(2)
  2. local arg = { ... }
  3. if not arg[2] then
  4. currentBPTV = ""
  5. else
  6. currentBPTV = arg[2]
  7. end
  8. --rednet.open("back") -- This was deleted, because it caused incompability with turtles.
  9. --sleep(0.1)
  10. if not arg[5] then
  11. write("Connecting to CraftScripts.com...")
  12. end
  13. h = http.get("http://www.craftscripts.com/binOS/"..currentBPTV)
  14. if h then
  15. term.setTextColor(colors.green)
  16. if not arg[5] then
  17. print("Success.")
  18. end
  19. term.setTextColor(colors.blue)
  20. if not arg[5] then
  21. print("Connected, file "..arg[3].." downloaded successful.")
  22. end
  23. --print("Connected.")
  24. --sleep(1)
  25. if arg[1] == "show" then
  26. if arg[3] == "clear" then
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. --print("Your files, found on server:")
  30. end
  31. print(h.readAll())
  32. else
  33. local file = fs.open(arg[3], "w")
  34. file.write(h.readAll())
  35. --print("Downloading file...")
  36. --sleep(0.5)
  37. --print("Finished.")
  38. file.close()
  39. h.close()
  40. end
  41. else
  42. term.setTextColor(colors.red)
  43. -- print("Failed.")
  44. -- print("Something is going wrong.")
  45. end
  46. term.setTextColor(colors.blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement