Advertisement
subbway

ksnfsdnfks

Jul 23rd, 2017
69
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.       turtle.dig()
  119.       turtle.forward()
  120.       if (i % 2 ~= 0) then
  121.         if direction then
  122.           posX = posX + 1
  123.         else
  124.           posX = posX - 1
  125.         end
  126.       else
  127.         if direction then
  128.           posX = posX - 1
  129.         else
  130.           posX = posX + 1
  131.         end
  132.       end
  133.       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
  134.         turtle.turnLeft()
  135.         turtle.select(2)
  136.         turtle.place()
  137.         turtle.turnRight()
  138.       end
  139.     end
  140.     if j < y then
  141.       if direction then
  142.         turtle.turnRight()
  143.         turtle.dig()
  144.         turtle.forward()
  145.         turtle.turnRight()
  146.         direction = false
  147.       else
  148.         turtle.turnLeft()
  149.         turtle.dig()
  150.         turtle.forward()
  151.         turtle.turnLeft()
  152.         direction = true
  153.       end
  154.       if(i % 2 ~= 0) then
  155.         posY = posY + 1
  156.       else
  157.         posY = posY - 1
  158.       end
  159.     end
  160.     if(turtle.getItemCount(16) > 0) then
  161.         goUnload(direction, inventory_start)
  162.     end
  163.   end  
  164.   if i < z then
  165.     turtle.digUp()
  166.     turtle.up()
  167.     posZ = posZ + 1
  168.     turtle.turnRight()
  169.     turtle.turnRight()
  170.   end
  171. end
  172.  
  173.  
  174.  
  175.  
  176. if z % 2 == 0 then
  177.   for i = 1, z do
  178.     turtle.down()
  179.     posZ = posZ - 1
  180.   end
  181.   turtle.turnRight()
  182.   for inventory = inventory_start, 16 do
  183.     turtle.select(inventory)
  184.     turtle.drop()
  185.   end
  186.   turtle.turnRight()
  187. else
  188.   if y % 2 == 0 then
  189.     turtle.turnRight()
  190.     for i = 1, y-1 do
  191.       turtle.forward()
  192.       posY = posY - 1
  193.     end
  194.     for i = 1, z do
  195.       turtle.down()
  196.       posZ = posZ - 1
  197.     end
  198.     for inventory = inventory_start, 16 do
  199.       turtle.select(inventory)
  200.       turtle.drop()
  201.     end
  202.     turtle.turnRight()
  203.   else
  204.     turtle.turnLeft()
  205.     for i = 1, y-1 do
  206.       turtle.forward()
  207.       posY = posY - 1
  208.     end
  209.     turtle.turnLeft()
  210.     for i = 1, x-1 do
  211.       turtle.forward()
  212.       posX = posX - 1
  213.     end
  214.     for i = 1, z do
  215.       turtle.down()
  216.       posZ = posZ - 1
  217.     end
  218.     turtle.turnRight()
  219.     for inventory = inventory_start, 16 do
  220.       turtle.select(inventory)
  221.       turtle.drop()
  222.     end
  223.     turtle.turnRight()
  224.   end
  225. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement