Advertisement
Roukurai

Butter's block detector-placer AI

Jan 21st, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. local x = 1
  2. turtle.select(x)
  3. redstone.setOutput("back",false)
  4. redstone.setOutput("left",false)
  5. redstone.setOutput("right",false)
  6.  
  7. function redAlert()
  8. redstone.setOutput("left",false)
  9. redstone.setOutput("right",false)
  10. redstone.setOutput("back",true)
  11. end
  12.  
  13. function detected()
  14. redstone.setOutput("right",false)
  15. redstone.setOutput("left",true)
  16. end
  17.  
  18. function notDetected()
  19. redstone.setOutput("left",false)
  20. redstone.setOutput("right",true)
  21. end
  22.  
  23. function check()
  24. if turtle.detect() == true then
  25. detected()
  26. stack()
  27. else
  28. notDetected()
  29. inventory()
  30. stack()
  31. end
  32. end
  33.  
  34. function stack()
  35. sleep(2)
  36. check()
  37. end
  38.  
  39. function fulfillment(stock)
  40. if stock == "y" then
  41. turtle.place()
  42. else
  43. end
  44. end
  45.  
  46. function inventory()
  47. turtle.select(x)
  48. if turtle.getItemCount() == 0 then
  49. x=x+1
  50. if x == 17 then
  51. redAlert()
  52. else
  53. inventory()
  54. end
  55. else
  56. fulfillment("y")
  57. end
  58. end
  59. check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement