Advertisement
hbar

colorprinter

Nov 14th, 2013
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. local supply = peripheral.wrap("right")
  2. supply.link()
  3. for i = 1,6 do
  4.     turtle.forward()
  5. end
  6.  
  7. local move = function(f)
  8.     while not f() do
  9.         sleep(0.3)
  10.     end
  11.     sleep(0.1)
  12. end
  13.  
  14. local place = function(color)
  15.     if turtle.getItemCount(1) < 2 then
  16.         supply.resupply(1)
  17.     end
  18.     turtle.place()
  19.     local lamp = peripheral.wrap("front")
  20.     lamp.setColor(tonumber(color,16))
  21. end
  22.  
  23. local f = fs.open("dw.txt","r")
  24.  
  25. local img = {}
  26.  
  27. line = f.readLine()
  28. while line ~= nil do
  29.     table.insert(img,line)
  30.     line = f.readLine()
  31. end
  32. f.close()
  33.  
  34. h,w = #img, #img[1]/8
  35. r,c = h,1
  36.  
  37. while true do
  38.     if c > w then break end
  39.     place(img[r]:sub(1+8*(c-1),1+8*(c-1)+7))
  40.     while r > 1 do
  41.         move(turtle.up)
  42.         r = r - 1
  43.         place(img[r]:sub(1+8*(c-1),1+8*(c-1)+7))
  44.     end
  45.     turtle.turnRight()
  46.     move(turtle.forward)
  47.     turtle.turnLeft()
  48.     c = c + 1
  49.     if c > w then break end
  50.     place(img[r]:sub(1+8*(c-1),1+8*(c-1)+7))
  51.     while r < h do
  52.         move(turtle.down)
  53.         r = r + 1
  54.         place(img[r]:sub(1+8*(c-1),1+8*(c-1)+7))
  55.     end
  56.     turtle.turnRight()
  57.     move(turtle.forward)
  58.     turtle.turnLeft()
  59.     c = c + 1
  60. end
  61.  
  62. if w % 2 == 1 then
  63.     while not turtle.detectDown() do
  64.         turtle.down()
  65.         sleep(0.3)
  66.     end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement