Advertisement
subbway

sdfsdf

Jul 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = {...}
  2. if #tArgs ~= 3 then
  3.   print("Requires length, width, height")
  4.   return
  5. end
  6.  
  7. local x = tonumber(tArgs[1]) - 1
  8. local y = tonumber(tArgs[2])
  9. local z = tonumber(tArgs[3])
  10.  
  11. local posX = 1
  12. local posY = 1
  13. local posZ = 1
  14.  
  15. if x == nil or y == nil or z == nil then
  16.   print("Invalid dimensions")
  17.   return
  18. end
  19.  
  20. if x < 0 or y < 0 or z < 0 then
  21.   print("Invalid (negative) dimensions")
  22.   return
  23. end
  24.  
  25. local torch = 0
  26. local inventory_start = 2
  27. print("Use torches? (y/n)")
  28. local input = io.read()
  29. if(input == "y") then
  30.   torch = 2
  31.   inventory_start = 3
  32. else
  33.   torch = 0
  34. end
  35.  
  36. local roomSize = x * y * z
  37. print("Storing fuel for mining process...")
  38. turtle.select(1)
  39. while turtle.getFuelLevel() < roomSize do
  40.   if not turtle.refuel(1) then
  41.     print("Not enough fuel. Please insert more fuel.")
  42.     return
  43.   end
  44. end
  45.  
  46.  
  47. --[[Funcao que vai descarregar quando e atingido o ultimo slot]]--
  48. function goUnload(direction, inventory_start)
  49.   turtle.down()
  50.   if(posZ % 2 == 0) then
  51.     if direction then
  52.       turtle.turnRight()
  53.     else
  54.       turtle.turnLeft()
  55.     end
  56.   else
  57.     if direction then
  58.       turtle.turnLeft()
  59.     else
  60.       turtle.turnRight()
  61.     end
  62.   end
  63.   for m = 1, posY-1 do
  64.     turtle.forward()
  65.   end
  66.   turtle.turnLeft()
  67.   for m = 1, posX-1 do
  68.     turtle.forward()
  69.   end
  70.   for m = 1, posZ-2 do
  71.     turtle.down()
  72.   end
  73.   turtle.turnRight()
  74.   for inventory = inventory_start, 16 do
  75.     turtle.select(inventory)
  76.     turtle.drop()
  77.   end
  78.   turtle.turnRight()
  79.   for m = 1, posZ-2 do
  80.     turtle.up()
  81.   end
  82.   for m = 1, posX-1 do
  83.     turtle.forward()
  84.   end
  85.   turtle.turnRight()
  86.   for m = 1, posY-1 do
  87.     turtle.forward()
  88.   end
  89.   if(posZ % 2 == 0) then
  90.     if direction then
  91.       turtle.turnRight()
  92.     else
  93.       turtle.turnLeft()
  94.     end
  95.   else
  96.     if direction then
  97.       turtle.turnLeft()
  98.     else
  99.       turtle.turnRight()
  100.     end
  101.   end
  102.   turtle.up()
  103.   turtle.select(inventory_start)
  104. end
  105.  
  106.  
  107.  
  108. local direction = true
  109. for i = 1, z do
  110.   roomSize = x * y * (z-i)
  111.   while turtle.getFuelLevel() < roomSize do
  112.     turtle.select(1)
  113.     turtle.refuel(1)
  114.   end
  115.  
  116.   for j = 1, y do
  117.     for k = 1, x do
  118.       while (turtle.detect()) do
  119.         turtle.dig()
  120.       end
  121.       while(turtle.forward() == false) do
  122.         turtle.dig()
  123.       end
  124.       if (i % 2 ~= 0) then
  125.         if direction then
  126.           posX = posX + 1
  127.         else
  128.           posX = posX - 1
  129.         end
  130.       else
  131.         if direction then
  132.           posX = posX - 1
  133.         else
  134.           posX = posX + 1
  135.         end
  136.       end
  137.       if(torch ~=0 and z > 1 and y > 1 and (j+3) % 6 == 0 and i == 1 and k < x and (k == 1 or k % 6 == 0)) then
  138.         turtle.turnLeft()
  139.         turtle.select(2)
  140.         turtle.place()
  141.         turtle.turnRight()
  142.       end
  143.     end
  144.     if j < y then
  145.       if direction then
  146.         turtle.turnRight()
  147.         while (turtle.detect()) do
  148.           turtle.dig()
  149.         end
  150.         while(turtle.forward() == false) do
  151.           turtle.dig()
  152.         end
  153.         turtle.turnRight()
  154.         direction = false
  155.       else
  156.         turtle.turnLeft()
  157.         while (turtle.detect()) do
  158.           turtle.dig()
  159.         end
  160.         while(turtle.forward() == false) do
  161.           turtle.dig()
  162.         end
  163.         turtle.turnLeft()
  164.         direction = true
  165.       end
  166.       if(i % 2 ~= 0) then
  167.         posY = posY + 1
  168.       else
  169.         posY = posY - 1
  170.       end
  171.     end
  172.     if(turtle.getItemCount(16) > 0) then
  173.         goUnload(direction, inventory_start)
  174.     end
  175.   end  
  176.   if i < z then
  177.     while (turtle.detectUp()) do
  178.       turtle.digUp()
  179.     end
  180.     turtle.up()
  181.     posZ = posZ + 1
  182.     turtle.turnRight()
  183.     turtle.turnRight()
  184.   end
  185. end
  186.  
  187.  
  188.  
  189.  
  190. if z % 2 == 0 then
  191.   for i = 1, z do
  192.     turtle.down()
  193.     posZ = posZ - 1
  194.   end
  195.   turtle.turnRight()
  196.   for inventory = inventory_start, 16 do
  197.     turtle.select(inventory)
  198.     turtle.drop()
  199.   end
  200.   turtle.turnRight()
  201. else
  202.   if y % 2 == 0 then
  203.     turtle.turnRight()
  204.     for i = 1, y-1 do
  205.       turtle.forward()
  206.       posY = posY - 1
  207.     end
  208.     for i = 1, z do
  209.       turtle.down()
  210.       posZ = posZ - 1
  211.     end
  212.     for inventory = inventory_start, 16 do
  213.       turtle.select(inventory)
  214.       turtle.drop()
  215.     end
  216.     turtle.turnRight()
  217.   else
  218.     turtle.turnLeft()
  219.     for i = 1, y-1 do
  220.       turtle.forward()
  221.       posY = posY - 1
  222.     end
  223.     turtle.turnLeft()
  224.     for i = 1, x-1 do
  225.       turtle.forward()
  226.       posX = posX - 1
  227.     end
  228.     for i = 1, z do
  229.       turtle.down()
  230.       posZ = posZ - 1
  231.     end
  232.     turtle.turnRight()
  233.     for inventory = inventory_start, 16 do
  234.       turtle.select(inventory)
  235.       turtle.drop()
  236.     end
  237.     turtle.turnRight()
  238.   end
  239. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement