Mxx123456

Untitled

Mar 1st, 2020
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. num_const=0
  2. num=0
  3. depth_const=2
  4. length_const=16
  5. width_const=5
  6. halflength=0
  7. level=18
  8. depth=0
  9. width=0
  10. length=0
  11. temp=0
  12. function EVEN_ODD()
  13.   temp=length_const
  14.   if temp%2==1 then
  15.     length_const=length_const-1
  16.     halflength_const=length_const/2
  17.   else
  18.     halflength_const=length_const/2
  19.   end
  20. end
  21. function MOVE_FORWARD(slot)
  22.   turtle.select(slot)
  23.   while not turtle.forward() do
  24.     turtle.attack()
  25.     turtle.dig()
  26.   end
  27.   if turtle.getItemSpace(slot)>30 then
  28.     turtle.placeDown()
  29.     return(slot-1)
  30.   else
  31.     turtle.placeDown()
  32.     return(slot)
  33.   end
  34. end
  35. function ONE_LINE(sslot)
  36.   while width ~= width_const do
  37.     sslot=MOVE_FORWARD(sslot)
  38.     sslot=sslot+1
  39.  
  40.     width=width+1
  41.   end
  42.   width=0
  43.   return(sslot)
  44. end
  45. function RIGHT()
  46.   turtle.turnRight()
  47.   sslot=MOVE_FORWARD(sslot)
  48.   turtle.turnRight()
  49. end
  50. function LEFT()
  51.   turtle.turnLeft()
  52.   sslot=MOVE_FORWARD(sslot)
  53.   turtle.turnLeft()
  54. end
  55. function ONE_LAYER()
  56.   sslot=1
  57.   while length ~= length_const do
  58.     sslot=MOVE_FORWARD(sslot)
  59.     sslot=sslot+1
  60.     length=length+1
  61.   end
  62.   turtle.turnLeft()
  63.   while halflength ~= halflength_const do
  64.     sslot=ONE_LINE(sslot)
  65.     LEFT()
  66.     sslot=ONE_LINE(sslot)
  67.     RIGHT()
  68.     halflength=halflength+1
  69.   end
  70.   length=0
  71.   halflength=0
  72.   turtle.turnRight()
  73. end
  74. function UP()
  75.  
  76.   while not turtle.up() do
  77.     turtle.attackUp()
  78.   end
  79. end
  80. function DOWN()
  81.   while not turtle.down() do
  82.     turtle.attackDown()
  83.     turtle.digDown()
  84.   end
  85. end
  86. function TURN()
  87.   turtle.turnLeft()
  88.   turtle.turnLeft()
  89. end
  90.  
  91. function DROP_ALL()
  92.   space=1
  93.   while space<17 do
  94.     turtle.select(space)
  95.     turtle.drop()
  96.     space=space+1
  97.   end
  98. end
  99. function GET_TO_START()
  100.   num=0
  101.   turtle.turnLeft()
  102.   while num ~= num_const do
  103.     if level == 0 then
  104.       while not turtle.forward() do
  105.         turtle.attack()
  106.         turtle.dig()
  107.       end
  108.     else
  109.       while not turtle.forward() do
  110.         sleep(1)
  111.       end
  112.     end
  113.     num=num+1
  114.   end
  115.   turtle.turnRight()
  116.   depth=level
  117.   while depth~=0 do
  118.     DOWN()
  119.     depth=depth-1
  120.   end
  121. end
  122. function RETURN_AND_REFUEL()
  123.   depth=0
  124.   temp=level
  125.   while depth ~= temp do
  126.     UP()
  127.     depth=depth+1
  128.   end
  129.   while not turtle.up() do
  130.     sleep(1)
  131.   end
  132.   if num_const~=0 then
  133.     while not turtle.up() do
  134.       sleep(1)
  135.     end
  136.   end
  137.   turtle.turnRight()
  138.   while num ~= 0 do
  139.     while not turtle.forward() do
  140.       sleep(1)
  141.     end
  142.     num=num-1
  143.   end
  144.   if num_const ~= 0 then
  145.     while not turtle.down() do
  146.       sleep(1)
  147.     end
  148.   end
  149.   if turtle.getFuelLevel()<1000 then
  150.     turtle.turnRight()
  151.     turtle.suck()
  152.     turtle.refuel()
  153.     TURN()
  154.   else
  155.     turtle.turnLeft()
  156.   end
  157.   while not turtle.down() do
  158.     sleep(1)
  159.   end
  160.   GET_TO_START()
  161.   level = level+1
  162. end
  163. function START()
  164.   --print("enter width")
  165.   --width_const=tonumber(read())
  166.   --if width_const<=1 then
  167.   --    width_const=2
  168.   --    print("width can't be less then 2. Now it is 2.")
  169.   --end
  170.   print("enter depth")
  171.   depth_const=tonumber(read())
  172.   print("enter turt number")
  173.   num_const=tonumber(read())
  174.   num_const=num_const*11
  175.   print("enter level")
  176.   level=tonumber(read())
  177.   if turtle.getFuelLevel() <1000 then
  178.     TURN()
  179.     turtle.suck()
  180.     turtle.refuel()
  181.     TURN()
  182.   end
  183. end
  184. START()
  185. EVEN_ODD()
  186. DOWN()
  187. GET_TO_START()
  188. --depth_const = level+depth_const
  189. while level~=depth_const do
  190.   ONE_LAYER()
  191.   RETURN_AND_REFUEL()
  192. end
Add Comment
Please, Sign In to add comment