TwistedDoor

break_grown_wheat

Jan 20th, 2022 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. local keep_running = true
  2. local block_exists = false
  3. local block_data_table = {}
  4. while keep_running do
  5. block_exists = false
  6. block_data_table = {}
  7. if turtle.inspectUp() and turtle.inspect() then
  8. block_exists, block_data_table = turtle.inspectUp()
  9. end
  10. if block_exists and block_data_table["state"]["powered"] then
  11. block_exists, block_data_table = turtle.inspect()
  12. -- Prints out something like this:
  13. -- {
  14. -- name = "minecraft:wheat",
  15. -- state = { age = 2, },
  16. -- }
  17. print(textutils.serialize(block_data_table))
  18. -- Prints "minecraft:wheat"
  19. print(block_data_table["name"])
  20. -- Prints 2
  21. print(textutils.serialize(block_data_table["state"]["age"]))
  22. -- If wheat is fully grown, break it
  23. if block_data_table["state"]["age"] == 7 then
  24. turtle.dig()
  25. end
  26. else
  27. print("No block in front of the turtle or lever above isn't on.")
  28. end
  29. sleep(0.5)
  30. end
Advertisement
Add Comment
Please, Sign In to add comment