Advertisement
subbway

zdfxdfsf

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