Advertisement
subbway

sadasdad

Jul 23rd, 2017
63
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. print(inventory_start)
  37.  
  38. local roomSize = x * y * z
  39. print("Storing fuel for mining process...")
  40. turtle.select(1)
  41. while turtle.getFuelLevel() < roomSize do
  42.   if not turtle.refuel(1) then
  43.     print("Not enough fuel. Please insert more fuel.")
  44.     return
  45.   end
  46. end
  47.  
  48.  
  49. --[[Funcao que vai descarregar quando e atingido o ultimo slot]]--
  50. function goUnload(direction, inventory_start)
  51.   print(inventory_start)
  52.   local test = inventory_start
  53.   if direction then
  54.     turtle.turnLeft()
  55.   else
  56.     turtle.turnRight()
  57.   end
  58.   if(posZ % 2 == 0) then
  59.     turtle.down()
  60.   end
  61.   for m = 1, posY-1 do
  62.     turtle.forward()
  63.   end
  64.   turtle.turnLeft()
  65.   for m = 1, posX-1 do
  66.     turtle.forward()
  67.   end
  68.   for m = 1, posZ-2 do
  69.     turtle.down()
  70.   end
  71.   turtle.turnRight()
  72.   for inventory = inventory_start, 16 do
  73.     turtle.select(inventory)
  74.     turtle.drop()
  75.   end
  76.   turtle.turnRight()
  77.   for m = 1, posZ-2 do
  78.     turtle.up()
  79.   end
  80.   for m = 1, posX-1 do
  81.     turtle.forward()
  82.   end
  83.   turtle.turnRight()
  84.   for m = 1, posY-1 do
  85.     turtle.forward()
  86.   end
  87.   if direction then
  88.     turtle.turnLeft()
  89.   else
  90.     turtle.turnRight()
  91.   end
  92.   if(posZ % 2 == 0) then
  93.     turtle.up()
  94.   end
  95.   turle.select(test)
  96. end
  97.  
  98.  
  99.  
  100. local direction = true
  101. for i = 1, z do
  102.   roomSize = x * y * (z-i)
  103.   while turtle.getFuelLevel() < roomSize do
  104.     turtle.select(1)
  105.     turtle.refuel(1)
  106.   end
  107.  
  108.   for j = 1, y do
  109.     for k = 1, x do
  110.       turtle.dig()
  111.       turtle.forward()
  112.       if direction then
  113.         posX = posX + 1
  114.       else
  115.         posX = posX - 1
  116.       end
  117.       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
  118.         turtle.turnLeft()
  119.         turtle.select(2)
  120.         turtle.place()
  121.         turtle.turnRight()
  122.       end
  123.     end
  124.     if j < y then
  125.       if direction then
  126.         turtle.turnRight()
  127.         turtle.dig()
  128.         turtle.forward()
  129.         posY = posY + 1
  130.         turtle.turnRight()
  131.         direction = false
  132.       else
  133.         turtle.turnLeft()
  134.         turtle.dig()
  135.         turtle.forward()
  136.         posY = posY + 1
  137.         turtle.turnLeft()
  138.         direction = true
  139.       end
  140.     end
  141.     if(turtle.getItemCount(16) > 0) then
  142.         goUnload(direction, inventory_start)
  143.     end
  144.   end  
  145.   if i < z then
  146.     turtle.digUp()
  147.     turtle.up()
  148.     posZ = posZ + 1
  149.     turtle.turnRight()
  150.     turtle.turnRight()
  151.     if direction then
  152.       direction = false
  153.     else
  154.       direction = true
  155.     end
  156.   end
  157. end
  158.  
  159.  
  160.  
  161.  
  162. if z % 2 == 0 then
  163.   for i = 1, z do
  164.     turtle.down()
  165.     posZ = posZ - 1
  166.   end
  167.   turtle.turnRight()
  168.   for inventory = inventory_start, 16 do
  169.     turtle.select(inventory)
  170.     turtle.drop()
  171.   end
  172.   turtle.turnRight()
  173. else
  174.   if y % 2 == 0 then
  175.     turtle.turnRight()
  176.     for i = 1, y-1 do
  177.       turtle.forward()
  178.       posY = posY - 1
  179.     end
  180.     for i = 1, z do
  181.       turtle.down()
  182.       posZ = posZ - 1
  183.     end
  184.     for inventory = inventory_start, 16 do
  185.       turtle.select(inventory)
  186.       turtle.drop()
  187.     end
  188.     turtle.turnRight()
  189.   else
  190.     turtle.turnLeft()
  191.     for i = 1, y-1 do
  192.       turtle.forward()
  193.       posY = posY - 1
  194.     end
  195.     turtle.turnLeft()
  196.     for i = 1, x-1 do
  197.       turtle.forward()
  198.       posX = posX - 1
  199.     end
  200.     for i = 1, z do
  201.       turtle.down()
  202.       posZ = posZ - 1
  203.     end
  204.     turtle.turnRight()
  205.     for inventory = inventory_start, 16 do
  206.       turtle.select(inventory)
  207.       turtle.drop()
  208.     end
  209.     turtle.turnRight()
  210.   end
  211. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement