SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Locals Variables
  2. local noFuelNeeded = 0 -- Check if turtle is using no fuel config
  3. local itemFuel = turtle.getItemCount(1) -- Fuel Slot 1
  4. local itemFuel1 = turtle.getItemCount(2) -- Fuel Slot 2
  5. local chest = turtle.getItemCount(3) -- Chest Slot 3
  6. local distance = 0 -- Distance will dig
  7. local distanceCount = 0 -- Count the distance
  8. local missingFuel = 0 -- If there is missing fuel this will be 1
  9. local missingChest = 0 -- If there is missing chest this will be 1
  10.  
  11. -- Checking On Items
  12. local function checking()
  13.     if noFuelNeeded == 0 then
  14.         if itemFuel == 0 then
  15.             missingFuel = 1
  16.         else
  17.             missingFuel = 0
  18.         end
  19.     end
  20.     if chest == 0 then
  21.         missingChest = 1
  22.     else
  23.         missingChest = 0
  24.     end
  25.     if missingFuel == 1 then
  26.         print("Missing Fuel in Slot 1")
  27.     end
  28.     if missingChest == 1 then
  29.         print("Missing Chest in Slot 3")
  30.     end
  31. end
  32.  
  33. local function recheck()
  34.     itemFuel = turtle.getItemCount(1)
  35.     itemFuel1 = turtle.getItemCount(2)
  36.     chest = turtle.getItemCount(3)
  37. end
  38.  
  39. local function reFuel()
  40.     if noFuelNeeded == 0 then
  41.         repeat
  42.             if turtle.getFuelLevel() < 120 then
  43.                 if itemFuel > 1 then
  44.                     turtle.select(1)
  45.                     turtle.refuel(1)
  46.                     itemFuel = itemFuel - 1
  47.                     turtle.select(4)
  48.                 elseif itemFuel1 > 1 then
  49.                     turtle.select(2)
  50.                     turtle.refuel(1)
  51.                     itemFuel1 = itemFuel1 - 1
  52.                     turtle.select(4)
  53.                 else
  54.                     print("out of fuel")
  55.                     os.shutdown()
  56.                 end
  57.             end
  58.         until turtle.getFuelLevel() >= 120
  59.     end
  60. end
  61.  
  62. local function dig()
  63.     turtle.dig()
  64.     turtle.forward()
  65.     turtle.turnLeft()
  66.     turtle.dig()
  67.     turtle.turnRight()
  68.     turtle.turnRight()
  69.     turtle.dig()
  70.     turtle.digUp()
  71.     turtle.up()
  72.     turtle.dig()
  73.     turtle.turnRight()
  74.     turtle.turnRight()
  75.     turtle.dig()
  76.     turtle.digUp()
  77.     turtle.up()
  78.     turtle.dig()
  79.     turtle.turnRight()
  80.     turtle.turnRight()
  81.     turtle.dig()
  82.     turtle.down()
  83.     turtle.down()
  84.     turtle.turnLeft()
  85. end
  86.  
  87. local function chestDump()
  88.     if turtle.getItemCount(16)> 0 then -- If slot 16 in turtle has item slot 4 to 16 will go to chest
  89.         if Chest ~= 0 then
  90.             turtle.select(3)
  91.             turtle.digDown()
  92.             turtle.placeDown()
  93.             for slot = 4, 16 do
  94.                 turtle.select(slot)
  95.                 sleep(0.6) -- Small fix for slow pc because i had people problem with this
  96.                 turtle.dropDown()
  97.             end
  98.         turtle.select(4)
  99.         else
  100.             print("Out Of Chest")
  101.             os.shutdown()
  102.         end
  103.     end
  104. end
  105.  
  106. function main()
  107.     repeat
  108.         reFuel()
  109.         dig()
  110.         distanceCount = distanceCount + 1
  111.         chestDump()
  112.     until distance == distanceCount
  113. end
  114.  
  115. function start()
  116.     print("Welcome!")
  117.     print("This 3x3 Tunnel Program 4x4 is coming soon after this one is done")
  118.     print("Please input your fuel in slot 1 and optionally also in slot 2 and chests in Slot 3")
  119.     print("Please Input Your Distance You Want Turtle To Dig")
  120.     input = io.read()
  121.     distance = tonumber(input)
  122.     print("Turtle Will Dig " .. distance .. " Long")
  123.     if turtle.getFuelLevel() == "unlimited" then -- just check if config of fuel is to unlimited
  124.     noFuelNeeded = 1
  125.     end
  126.     checking()
  127.     if missingFuel == 1 or missingChest == 1 then
  128.         repeat
  129.             print("Please Put In Items That Are Missing")
  130.             sleep(10)
  131.             recheck()
  132.             checking()
  133.         until missingFuel == 0 and missingChest == 0
  134.     end
  135.     main()
  136. end
  137.  
  138. start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top