Advertisement
krakaen

ComputerCraft Pastebin FIX

Mar 27th, 2017
2,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. local function get(paste)
  2.     local response = http.get("https://pastebin.com/raw/"..textutils.urlEncode( paste ))
  3.  
  4.     if response then
  5.         local sResponse = response.readAll()
  6.         response.close()
  7.         return sResponse
  8.     else
  9.         print( "Failed." )
  10.     end
  11. end
  12.  
  13. local tArgs = { ... }
  14. local sCode = tArgs[2]
  15. local sFile = tArgs[3]
  16. local res = get(sCode)
  17. if res then
  18.     local file = fs.open( shell.resolve( sFile ), "w" )
  19.     file.write( res )
  20.     file.close()
  21.  
  22.     print( "Downloaded as "..sFile )
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement