Advertisement
superjaja05

Untitled

Sep 15th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local replace1 = args[1]
  4.  
  5. turn1 = 0
  6.  
  7. if replace1 == "true" then
  8. block1 = turtle.getItemDetail()["name"]
  9. textutils.slowPrint("Selected Block:"..block1)
  10. end
  11.  
  12. function search()
  13. print("Initalizing search for: "..block1)
  14. slot1 = 1
  15. done1 = false
  16. repeat
  17. print("Searching slot "..slot1)
  18. if turtle.getItemDetail(slot1) ~= nil then
  19. if turtle.getItemDetail(slot1)["name"] == block1 then
  20. turtle.select(slot1)
  21. turtle.transferTo(1)
  22. turtle.select(1)
  23. break
  24. else
  25. slot1 = slot1+1
  26. end
  27. else
  28. slot1 = slot1+1
  29. end
  30. if slot1 == 16 and turtle.getItemDetail(16) == nil then
  31. os.sleep(2)
  32. textutils.slowPrint("Not found.. rebooting")
  33. os.reboot()
  34. end
  35. until done1 == true
  36. end
  37.  
  38. function rs()
  39. turtle.dig()
  40. if replace1 == "true" then
  41. turtle.place()
  42. end
  43. end
  44.  
  45. function turn()
  46. turtle.forward()
  47. turtle.turnLeft()
  48. turn1 = turn1+1
  49. end
  50.  
  51. function start()
  52. repeat
  53. rs()
  54. repeat
  55. if replace1 == "true" then
  56. if turtle.getItemDetail() ~= nil then
  57. if turtle.getItemDetail()["name"] ~= block1 then
  58. search()
  59. end
  60. end
  61. if turtle.getItemDetail() == nil then
  62. search()
  63. end
  64. end
  65. if (turn1 % 2 == 0) then
  66. turtle.up()
  67. else
  68. turtle.down()
  69. end
  70. rs()
  71. until turtle.inspectDown() == true or turtle.inspectUp() == true
  72. turtle.turnRight()
  73. if turtle.inspect() == true then
  74. done2 = true
  75. else
  76. done2 = false
  77. end
  78. turn()
  79. until done2 == true
  80. end
  81.  
  82. start()
  83.  
  84.  
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement