Guest User

Untitled

a guest
Mar 22nd, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. function getPastebin( code, path ) -- Credits to the devs of CC
  2.     local response = http.get(
  3.         "http://pastebin.com/raw.php?i=" .. textutils.urlEncode( code )
  4.         )
  5.     if response then
  6.         local contents = response.readAll()
  7.         local file = fs.open( path, "w" )
  8.         file.write( contents )
  9.         file.close()
  10.         return true
  11.     else
  12.         return false
  13.     end
  14. end
  15.  
  16. local fail = false
  17. for i = 1, #tPB do
  18.     term.setCursorPos( 13, 7 )
  19.     term.clearLine()
  20.     write( "Downloading file: " .. tPB[i][1] )
  21.     term.setCursorPos( 13, 8 )
  22.     term.clearLine()
  23.     write( "To path: " .. tPB[i][2] )
  24.     if getPastebin( tPB[i][1], tPB[i][2] ) then
  25.         loadBar()
  26.     else
  27.         fail = true
  28.         break
  29.     end
  30. end
  31.    
  32. if fail then
  33.     term.clear()
  34.     term.setCursorPos( 1, 5 )
  35.     print( "Could not download a file, please restart if your internet is working properly again" )
  36.     local evt = os.pullEvent()
  37.     if evt then
  38.         term.setBackgroundColor( colors.black )
  39.         term.setTextColor( colors.white )
  40.         term.clear()
  41.         term.setCursorPos( 1, 1 )
  42.         if not disc then
  43.             fs.delete( "/myOS" )
  44.         end
  45.         return
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment