asteroidsteam

download

Aug 11th, 2017
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. term.setBackgroundColor(colors.green)
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. term.setBackgroundColor(colors.blue)
  5. term.clearLine()
  6. term.setCursorPos(1,2)
  7. term.clearLine()
  8. term.setCursorPos(1,1)
  9. write("Type Link to download from:")
  10. term.setCursorPos(1,2)
  11. local link = read()
  12. local function get(link_)
  13.   if (http.checkURL(link_)) then
  14.     local data_ = http.get(link_)
  15.     local readall_ = data_.readAll()
  16.     return readall_
  17.   else
  18.     return "a"
  19.   end
  20. end
  21. if (get(link) == "a") then
  22.     term.setCursorPos(1,2)
  23.   term.clearLine()
  24.   write("Error: Invalid link!")
  25.   sleep(3)
  26.   dofile("/os/desktop")
  27. else
  28.  
  29. if (fs.exists("download.tmp")) then
  30.     fs.delete("download.tmp")
  31.   end
  32.   local file = fs.open("download.tmp","w")
  33.   local dat = get(link)
  34.   file.write(dat)
  35.   file.close()
  36.   term.setCursorPos(1,1)
  37.   write(dat)
  38.   sleep(3)
  39.   dofile("/os/desktop")
  40. end
Add Comment
Please, Sign In to add comment