Advertisement
Guest User

mine

a guest
Feb 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. function refuel(min)
  2.  if turtle.getFuelLevel() < min then
  3.   turtle.select(1)
  4.   while turtle.getFuelLevel() < min do
  5.    turtle.refuel(1)
  6.   end
  7.  else
  8.   return true
  9.  end
  10. end
  11. function forward()
  12.  if not turtle.forward() then
  13.   turtle.attack()
  14.   turtle.dig()
  15.   forward()
  16.  end
  17. end
  18. function upward()
  19.  if not turtle.up() then
  20.   turtle.digUp()
  21.   upward()
  22.  end
  23. end
  24. function downward()
  25.  if not turtle.down() then
  26.   turtle.digDown()
  27.   downward()
  28.  end
  29. end
  30. function inspectOre(s,d)
  31.  if s then
  32.   if d.name == "minecraft:iron_ore" or d.name == "minecraft:diamond_ore" or d.name == "minecraft:gold_ore" or d.name == "minecraft:coal_ore" or d.name == "minecraft:redstone_ore" then
  33.    return true
  34.   end
  35.  end
  36.  return false
  37. end
  38. function checkForOres()
  39.  if inspectOre(turtle.inspect()) then
  40.   forward()
  41.   checkForOres()
  42.   turtle.back()
  43.  end
  44.  turtle.turnRight()
  45.  if inspectOre(turtle.inspect()) then
  46.   forward()
  47.   checkForOres()  
  48.   turtle.back()
  49.  end
  50.  turtle.turnLeft()
  51.  turtle.turnLeft()
  52.  if inspectOre(turtle.inspect()) then
  53.   forward()
  54.   checkForOres()
  55.   turtle.back()
  56.  end
  57.  turtle.turnRight()
  58.  
  59.  if inspectOre(turtle.inspectUp()) then
  60.   upward()
  61.   checkForOres()
  62.   turtle.down()
  63.  end
  64.  
  65.  if inspectOre(turtle.inspectDown()) then
  66.   downward()
  67.   checkForOres()
  68.   turtle.up()
  69.  end
  70. end
  71. print("How many blocks do you want to mine")
  72. local amount = read()
  73. count = 1
  74. for i=1,amount do
  75.  if refuel(count) then
  76.   forward()
  77.   checkForOres()
  78.   count=count+1
  79.  else
  80.   print("not enough Fuel")
  81.   break
  82.  end
  83. end
  84. for j=1,count do
  85.  turtle.back()
  86. end
  87. print("----------DONE-----------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement