MrHG

geode

Aug 4th, 2022 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. -- geode scanner for turtles
  2. detectBlock = "tetra:block_geode"
  3. os.loadAPI("t")
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. turtle.select(1)
  7. print("now scanning for geodes...")
  8.  
  9. function isGeode(has_block,data)
  10. if has_block then
  11. if data.name == detectBlock then
  12. return true
  13. else
  14. return false
  15. end
  16. else
  17. return false
  18. end
  19. end
  20.  
  21. function scanGeode()
  22. if isGeode(turtle.inspectUp()) then
  23. t.up(1)
  24. scanGeode()
  25. t.down(1)
  26. end
  27. if isGeode(turtle.inspect()) then
  28. t.forward(1)
  29. scanGeode()
  30. t.back(1)
  31. t.up(1)
  32. end
  33. if isGeode(turtle.inspectDown()) then
  34. t.down(1)
  35. scanGeode()
  36. t.up(1)
  37. end
  38. end
  39.  
  40. while true do
  41. has_block, info = turtle.inspect()
  42. if has_block then
  43. if info.name == "minecraft:torch" then
  44. turtle.select(16)
  45. t.forward(1)
  46. scanGeode()
  47. t.forward(1)
  48. t.turnAround()
  49. t.place(16)
  50. t.turnAround()
  51. turtle.select(1)
  52. else
  53. if not returning then
  54. for i=1,5 do
  55. if not turtle.detectUp() then
  56. t.up()
  57. scanGeode()
  58. end
  59. end
  60. t.turnAround()
  61. print("returning..")
  62. returning = true
  63. else
  64. for i=1,5 do
  65. if not turtle.detectDown() then
  66. t.down()
  67. scanGeode()
  68. end
  69. end
  70. t.turnAround()
  71. print("Done!")
  72. break
  73. end
  74. end
  75. end
  76. t.forward(1)
  77. scanGeode()
  78. end
Advertisement
Add Comment
Please, Sign In to add comment