SHARE
TWEET

tunnel miner

a guest Jan 25th, 2020 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local distanceX = 0
  2. local fuelAmount = 0
  3. local fuel = 0
  4. light = 8
  5.  
  6. local items = {
  7.   ["minecraft:cobblestone"] = true,
  8.   ["minecraft:dirt"] = true,
  9.   ["minecraft:gravel"] = true,
  10.   ["minecraft:diorite"] = true,
  11.   ["minecraft:granite"] = true,
  12.   ["chisel:limestone2"] = true,
  13. }
  14.  
  15. function distAdd()
  16.   distanceX = distanceX + 1
  17. print("i have travelled" .. distance .. "blocks!"")
  18. end
  19.  
  20. function forward()
  21. if turtle.forward()
  22.                repeat
  23.                turtle.dig()
  24.                turtle.attack()
  25.                sleep(0.25)
  26.                until turtle.forward()
  27.                
  28. end
  29.  
  30. function placeLight()
  31.  if light == 0 then
  32.   turtle.select(2)
  33.   turtle.place()
  34.   else
  35.   light = light - 1
  36.  end
  37. end
  38.  
  39. function mine()
  40.  turtle.dig()
  41.  forward()
  42.  turtle.digDown()
  43.  turtle.digUp()
  44.  turtle.turnLeft()
  45.  turtle.dig()
  46.  forward()
  47.  turtle.digUp()
  48.  turtle.digDown()
  49.  turtle.dig()
  50.  forward()
  51.  turtle.digDown()
  52.  turtle.digUp()
  53.  turtle.turnLeft()
  54.  turtle.turnLeft()
  55.  forward()
  56.  forward()
  57.  turtle.turnLeft()
  58.  distAdd()
  59. end
  60.  
  61. function home()
  62.  return = distanceX
  63.  turtle.turnLeft()
  64.  turtle.turnLeft()
  65.  print("Returning home")
  66.    for i = 1,distanceX do
  67.      turtle.forward()
  68.    end
  69. end
  70.  
  71. function return()
  72. turtle.turnRight()
  73. turtle.turnRight()
  74. print("Returning to work")
  75.  for i = 1,return do
  76.    turtle.forward()
  77.  end
  78. end
  79.  
  80. fuelChk()
  81. turtle.select(1)
  82. fuel = turtle.getItemCount()
  83. end
  84.  
  85. function refuel()
  86.  turtle.select(1)
  87.    if turtle.refuel(0) = true then
  88.    amount = turtle.getItemCount()
  89.      if turtle.getItemCount() <= 1 then
  90.      print("Out of fuel")
  91.      else
  92.      turtle.refuel(amount - 1)
  93.    end
  94.  end
  95. end
  96.    
  97. function invChk()
  98.  for invent = 1,16 do
  99.  turtle.select(invent)
  100.  local data = turtle.getItemDetail()
  101.    if items[ data.name ] then
  102.    print("dropping" .. data.count .. "of" .. data.name.. ".")
  103.     turtle.drop()
  104.    end
  105.  end
  106. end
  107.  
  108. fuelChk()
  109. while fuel == distance * 2 do
  110. mine()
  111. invChk()
  112. end
  113. refuel()
  114. if fuel < distance * 2 then
  115.   print("out of fuel")
  116.   repeat
  117.   turtle.refuel()
  118.   until fuel > distance * 2
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