Advertisement
SirBaconBitz

IMG API V2

Apr 27th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. bridge = peripheral.wrap("right")
  2. function loadimg( url, startx, starty, white)
  3.   resp = http.post("http://ccpost.esy.es/hex.php","imgurl="..url)
  4.   y = starty
  5.   local line = resp.readLine()
  6.   while line do
  7.     x = startx
  8.     for color in line:gmatch('%S+') do
  9.       rgb = {}
  10.       for rgba in color:gmatch('[^%.]+') do
  11.         table.insert(rgb, rgba)
  12.       end
  13.       newcol = #rgb[2] ~= 3 and rgb[2] or rgb[2]..rgb[2]
  14.       if white == true then
  15.         if newcol ~= "ffffff" then
  16.           bridge.addBox(x,y,1,1,tonumber(newcol,16), 1 - rgb[1]/255)
  17.         end
  18.       elseif white == false then
  19.         bridge.addBox(x,y,1,1,tonumber(newcol,16), 1 - rgb[1]/255)
  20.       end
  21.      
  22.       x = x + 1
  23.     end
  24.     sleep(0.05)
  25.     y = y + 1
  26.     line = resp.readLine()
  27.   end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement