iconmaster

markers

Apr 11th, 2015
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. function forward(n)
  2.     for i=1,n do
  3.         if turtle.detect() then
  4.             repeat
  5.                 turtle.dig()
  6.             until not turtle.detect()
  7.         end
  8.         turtle.forward()
  9.     end
  10. end
  11.  
  12. function place()
  13.     if turtle.detect() then
  14.         turtle.digDown()
  15.     end
  16.     turtle.placeDown()
  17. end
  18.  
  19. function markers(w,h)
  20.     turtle.turnLeft()
  21.     forward(w/2)
  22.     place()
  23.     turtle.turnRight()
  24.     forward(h)
  25.     place()
  26.     turtle.turnRight()
  27.     forward(w)
  28.     place()
  29.     turtle.turnRight()
  30.     forward(h)
  31.     place()
  32.     turtle.turnRight()
  33.     forward(w/2)
  34. end
  35.  
  36. local args = {...}
  37. if #args==0 then
  38.     print("Usage: markers w [h]")
  39.     return
  40. end
  41. local w,h
  42. if #args==1 then
  43.     w = tonumber(args[1])
  44.     h = w
  45. else
  46.     w = tonumber(args[1])
  47.     h = tonumber(args[2])
  48. end
  49. markers(w,h)
Advertisement
Add Comment
Please, Sign In to add comment