Advertisement
LegoStax

Pastebin Quick Fix

Sep 18th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs < 2 then
  3.     print(fs.getName(shell.getRunningProgram()).." <code> <path>")
  4.     return
  5. end
  6.  
  7. if not fs.exists(tArgs[2]) then
  8.     -- Download
  9.     local response = http.get("http://pastebin.com/download.php?i="..tArgs[1])
  10.     if response then
  11.         print("Success.")
  12.         local data = response.readAll()
  13.         local f = fs.open(tArgs[2], "w")
  14.         f.write(data)
  15.         f.close()
  16.         print(tArgs[1].." has been saved to "..tArgs[2])
  17.     else
  18.         print("Failure to download.")
  19.     end
  20. else
  21.     print("File exists.")
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement