NoxiaZ

Untitled

Aug 29th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. slot = 1
  2. place = false
  3. function placeUp()
  4.    
  5.     if place then
  6.         if turtle.getItemCount(slot) == 0 then
  7.             slot = slot + 1
  8.         end          
  9.         turtle.select(slot)
  10.         turtle.placeUp()
  11.     end
  12. end
  13.  
  14. function placeBehind()
  15.  
  16.    
  17.     if place then
  18.         if turtle.getItemCount(slot) == 0 then
  19.             slot = slot + 1
  20.         end          
  21.         turtle.select(slot)
  22.         turtle.turnLeft()  
  23.         turtle.turnLeft()  
  24.         turtle.place()
  25.         turtle.turnLeft()  
  26.         turtle.turnLeft()  
  27.     end
  28. end
  29.  
  30. function goForward ()
  31.     placeUp()
  32.     turtle.dig()
  33.     turtle.forward()           
  34. end
  35.  
  36. function goUp()
  37.     placeBehind()
  38.     turtle.digUp();
  39.     turtle.up();   
  40. end
  41.  
  42.  function goDown()
  43.     placeBehind()
  44.     turtle.digDown();
  45.     turtle.down();
  46. end
  47.  
  48. function goLeft()
  49.     turtle.turnLeft()  
  50.     goForward()
  51.     turtle.turnLeft()
  52. end
  53.  
  54. function goRight()
  55.     turtle.turnRight() 
  56.     goForward()
  57.     turtle.turnRight()
  58. end
  59.  
  60. local args = { ... }
  61. if #args < 4 then
  62.     print("Parameters: <size> <depth> <place> <forward>")
  63. else
  64.    
  65.     local fn = tonumber(args[1])
  66.     local down = tonumber(args[2])
  67.     local needToGoLeft = false
  68.     local needToGoDown = false
  69.     if (args[3] == "1") then
  70.         place = true
  71.     end
  72.    
  73.     if args[4] == "1" then
  74.         local i = 0    
  75.         turtle.digDown()
  76.         turtle.down()  
  77.         while i < down do
  78.             local l = 0
  79.             while l < fn do
  80.                 local f = 1
  81.                 while f < fn do        
  82.                     goForward()
  83.                     f = f + 1
  84.                 end
  85.                 l = l + 1
  86.                 if (l < fn) then
  87.                     if (needToGoLeft) then
  88.                         goLeft()
  89.                         needToGoLeft = false
  90.                     else
  91.                         goRight()
  92.                         needToGoLeft = true
  93.                     end
  94.                 end
  95.             end
  96.             i = i + 1
  97.             if i < down then
  98.                 placeUp()  
  99.                 turtle.digDown()
  100.                 turtle.down()      
  101.                 turtle.turnLeft()  
  102.                 turtle.turnLeft()  
  103.             end
  104.         end
  105.     else
  106.         local i = 0
  107.         while i < down do
  108.             local l = 0
  109.             while l < fn do
  110.                 local f = 1
  111.                 while f < fn do    
  112.                     if needToGoDown then
  113.                         goDown()
  114.                     else               
  115.                         goUp()
  116.                     end
  117.                     f = f + 1
  118.                 end
  119.                 if needToGoDown then
  120.                     needToGoDown = false
  121.                 else
  122.                     needToGoDown = true    
  123.                 end
  124.                 placeBehind()
  125.                 l = l + 1
  126.                 if (l < fn) then
  127.                     if (needToGoLeft) then
  128.                         turtle.turnLeft()
  129.                         turtle.dig()
  130.                         turtle.forward()
  131.                         turtle.turnRight()
  132.                     else
  133.                         turtle.turnRight()
  134.                         turtle.dig()
  135.                         turtle.forward()
  136.                         turtle.turnLeft()
  137.                     end
  138.                 end
  139.             end
  140.             i = i + 1
  141.             if (needToGoLeft) then
  142.                 needToGoLeft = false
  143.             else
  144.                 needToGoLeft = true
  145.             end
  146.             if i < down then
  147.                 turtle.dig()
  148.                 turtle.forward()
  149.             end
  150.         end
  151.     end
  152. end
Advertisement
Add Comment
Please, Sign In to add comment