Left4Cake2

httpimg

Apr 24th, 2013
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local tArgs = { ... }
  2. if tArgs[2] then tArgs[2] = tArgs[2] + 0 end
  3. if tArgs[3] then tArgs[3] = tArgs[3] + 0 end
  4. if #tArgs > 0 then
  5.     if #tArgs == 2 then
  6.         scaleW = tArgs[2]
  7.         scaleH = tArgs[2]
  8.     elseif #tArgs > 2 then
  9.         scaleW = tArgs[2]
  10.         scaleH = tArgs[3]
  11.     else
  12.         scaleW = 1
  13.         scaleH = 1
  14.     end
  15.    
  16.     if scaleW <= 0 then
  17.         scaleW = 1
  18.     end
  19.  
  20.     if scaleH <= 0 then
  21.         scaleH = 1
  22.     end
  23.    
  24.    
  25.     local response = http.post("http://www.lozengia.com/tmas/Downloads/Minecraft/computercraft/CCimage.php", "image=" .. tArgs[1] .. "&scaleW=" .. scaleW .. "&scaleH=" .. scaleH)
  26.     if response then
  27.         while response do
  28.             local sResponse = response.readAll()
  29.             response.close()
  30.             shell.run( "clear" )
  31.             cache = shell.resolve( "image.nfp" )
  32.             local file = fs.open( cache, "w" )
  33.             file.write( sResponse )
  34.             file.close()
  35.             response = nil
  36.             shell.run( "npaintpro", "image.nfp" )
  37.         end
  38.     else
  39.         -- if image is not reseved
  40.         print( "Error, Could not load image." )
  41.     end
  42.  
  43. else
  44.     print("syntex 1: httpimg url")
  45.     print("syntex 2: httpimg url scale")
  46.     print("syntex 3: httpimg url scaleW scaleH")
  47.  
  48. end
Advertisement
Add Comment
Please, Sign In to add comment