Maxiride

t_flatten

May 31st, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. -- 1/6/13 Maxiride
  2. -- tflat v1.1
  3.  
  4. function fw() -- Forward function to avoid glitches with gravel falling down
  5.     while turtle.detect() do
  6.         turtle.dig()
  7.     end
  8. turtle.forward()
  9. end
  10.  
  11. function tr() -- Turn right function and 1 step fotward
  12. turtle.turnRight()
  13. fw()
  14. turtle.turnRight()
  15. end
  16.  
  17. function tl() -- Turn left function and 1 step forward
  18. turtle.turnLeft()
  19. fw()
  20. turtle.turnLeft()
  21. end
  22.  
  23. function up()
  24.     if turtle.detectUp() then
  25.         turtle.digUp()
  26.     end
  27. turtle.up()
  28.  
  29. if o==0 then
  30.     turtle.turnLeft()
  31.     turtle.turnLeft()
  32.     up()
  33.     else
  34.         turtle.turnRight()
  35.         turtle.turnRight()
  36.         up()
  37.  
  38. end
  39. end
  40.  
  41. function main()
  42. turtle.refuel()
  43. print ("Insert Lenght of the cleaning path (in front of the turtle)")
  44. len=read()
  45.  
  46. print("Insert Width of the cleaning path (on the right side of the turtle)")
  47. wid=read()
  48.  
  49. print ("Insert Height of the cleaning path (on top of the turtle)")
  50. hei=read()
  51.  
  52.  
  53. local o=0 -- Counter 1-0 for tr() or tf()
  54.  
  55. for i=1, hei do
  56.     for j=1, wid do
  57.         for k=1, len do
  58.             fw()
  59.             print("fw",k)
  60.         end
  61.        
  62.         print(o)
  63.         if (o==0 and (not(j==wid))) then
  64.             tr()
  65.             o=o+1
  66.             elseif (o==1 (not(j==wid))) then
  67.                 tl()
  68.                 o=o-1
  69.             else
  70.             up()
  71.         end
  72.        
  73.         print("wid",j)
  74.     end
  75.  
  76. print("Up!",i)
  77. end
  78. end
  79.  
  80. main()
Advertisement
Add Comment
Please, Sign In to add comment