Eco

turtleTunnelWide

Eco
Apr 22nd, 2021 (edited)
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get q4kqxzkx wTunnel
  2. -- rm wTunnel.lua                   To update  
  3.  
  4. function refuelTurtle()
  5.     print("Slot: " .. turtle.getSelectedSlot())
  6.     -- print("Item ID: " .. turtle.getItemDetail())  It's a table
  7.     print("Number of Items: " .. turtle.getItemCount())
  8.  
  9.     turtle.refuel()
  10.     print("Turtle refueled!")
  11. end
  12.  
  13. function digForward()
  14.     while turtle.detect() do
  15.         print("Digging forward!")
  16.         turtle.dig()
  17.     end
  18. end
  19.  
  20. function digUp()
  21.     while turtle.detectUp() do
  22.         --print("Digging Up!")
  23.         turtle.digUp()
  24.     end
  25. end
  26.  
  27. function digDown()
  28.     while turtle.detectDown() do
  29.         --print("Digging down!")
  30.         turtle.digDown()
  31.     end
  32. end
  33.  
  34. function moveForward()
  35.     if (turtle.detect() == false) then
  36.         print("Moving Forward!")
  37.         turtle.forward()
  38.     else
  39.         print("Block detected in Front!")
  40.         digForward()
  41.         turtle.forward()
  42.     end
  43. end
  44.  
  45. function moveUp()
  46.     if (turtle.detectUp() == false) then
  47.         print("Moving up!")
  48.         turtle.up()
  49.     else
  50.         print("Block detected above!")
  51.         digUp()
  52.         turtle.up()
  53.     end
  54. end
  55.  
  56. function turnRight()
  57.     print("Turning Right!")
  58.     turtle.turnRight()
  59.     --moveForward()
  60. end
  61.  
  62. function turnLeft()
  63.     print("Turning Left!")
  64.     turtle.turnLeft()
  65.     --moveForward()
  66. end
  67.  
  68. function inPosition()
  69.     turtle.forward()
  70.     moveForward()
  71.     digUp()
  72.     moveUp()
  73.     digUp()
  74.     print("We are now in position!")
  75. end
  76.  
  77.  
  78. function digCenter()
  79.     digForward()
  80.     moveForward()
  81.     digUp()
  82.     digDown()
  83. end
  84.  
  85.  
  86. -- put this in a function eventually
  87. --  local input = io.read("*n")      io.read() is read() in CC
  88.     print('How many blocks forward do you want to go?')
  89.     local input = read()
  90.     print('Now Mining ' .. input .. ' Blocks forward')
  91.     local input = tonumber(input)
  92.  
  93. function digCycle()
  94.     local blocks = 0
  95.     local turtleSlot = 2
  96.     local turtleBottomRightSlot = 15
  97.  
  98.         while blocks < input do
  99.  
  100.             -- 1 is top left, 16 bottom right, checks how many items in slot 16
  101.             if (turtle.getItemCount(turtleBottomRightSlot) >= 1) then
  102.                 print('Slot ' .. turtle.getSelectedSlot() .. ' has: ' .. turtle.getItemCount(turtleBottomRightSlot))
  103.                 -- print('Slot 9 holds: ' .. turtle.getItemDetail(turtleBottomRightSlot))
  104.                 -- attempt to concatenate string and table
  105.  
  106.                 -- select chest from bottom right, it was automatically consumed when in slot 1
  107.                 turtle.select(16)
  108.                 print('Selecting slot ' .. turtle.getSelectedSlot())
  109.                 --print('Current slot holds: ' .. turtle.getItemDetail())
  110.                 print('Currently Holding:' .. turtle.getItemCount() .. ' items')
  111.  
  112.                 print('Placing down a chest from slot ' .. turtle.getSelectedSlot())
  113.                 turtle.placeDown()
  114.  
  115.                 while turtleSlot < turtleBottomRightSlot do
  116.                     turtle.select(turtleSlot)
  117.                     print('Slot: '.. turtle.getSelectedSlot())
  118.                     --print('Item ID: ' .. turtle.getItemDetail())
  119.                     print('Amount: ' .. turtle.getItemCount() .. ' items')
  120.                     turtle.dropDown()
  121.  
  122.                     turtleSlot = turtleSlot+1
  123.                 end
  124.             end
  125.  
  126.             turnRight()  -- Turns doesn't move
  127.             digCenter()
  128.             digCenter()
  129.    
  130.             digCenter()
  131.             digCenter()
  132.             digCenter()
  133.    
  134.             digCenter()
  135.             digCenter()
  136.             digCenter()
  137.  
  138.             digCenter()
  139.             digCenter()
  140.             digCenter()
  141.  
  142.             digCenter()
  143.             digCenter()
  144.             digCenter()
  145.  
  146.             digCenter()
  147.             digCenter()
  148.             digCenter()
  149.        
  150.             turnLeft()
  151.             digCenter()
  152.        
  153.             turnLeft()
  154.             digCenter()
  155.             digCenter()
  156.    
  157.             digCenter()
  158.             digCenter()
  159.             digCenter()
  160.    
  161.             digCenter()
  162.             digCenter()
  163.             digCenter()
  164.  
  165.             digCenter()
  166.             digCenter()
  167.             digCenter()
  168.  
  169.             digCenter()
  170.             digCenter()
  171.             digCenter()
  172.  
  173.             digCenter()
  174.             digCenter()
  175.             digCenter()
  176.                            
  177.             turnRight()
  178.             digCenter()
  179.             blocks = blocks+1
  180.             print(blocks)
  181.         end
  182.  
  183. end
  184.  
  185. function returnBack()
  186.     local x = -3
  187.    
  188.     -- Get in position
  189.     turnRight()
  190.     digCenter()
  191.     digCenter()
  192.     turnRight()
  193.  
  194.     while x < input do
  195.         turtle.forward()
  196.         x = x + 1
  197.     end
  198.  
  199.     turnRight()
  200.     turtle.forward()
  201.     turtle.forward()
  202.     turnRight()
  203. end
  204.  
  205. refuelTurtle()
  206. inPosition()
  207.  
  208. digCycle()
  209.  
  210. returnBack()
  211.  
  212. print("Cycle Complete!")
  213.  
Add Comment
Please, Sign In to add comment