Dimencia

Testfarm4

Mar 21st, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. local fuelSlot = 1
  2. local seedSlot = 2
  3. -- Wheat has all other slots? Or just 3, idk
  4. local wheatSlot = 3
  5. local testSlot = 4
  6.  
  7. turtle.refuel()
  8. while(true) do
  9.  
  10. turtle.turnRight()
  11. -- Inspect the block in front of it
  12. local success, data = turtle.inspect()
  13. local hasBlockRight = success
  14. if success then
  15. -- data contains fields: name, tags, state
  16. print("Name: ", data.name)
  17. if data.name == "minecraft:wheat" then
  18. if data.state.age == 7 then
  19. -- Select the seeds to punch it
  20. turtle.select(seedSlot)
  21. turtle.attack("left") -- Do we need to stand on it and attack down? Do we need to specify "left" for attacking with seeds/hand?
  22. -- You think we can just turtle.place()? Try that later
  23. turtle.dig()
  24. turtle.suck()
  25. turtle.place()
  26. turtle.select(wheatSlot)
  27. turtle.suck()
  28. end
  29. end
  30. turtle.turnLeft() -- Turn back forward
  31. end -- If there's nothing in front of it, it can just keep going that way.
  32. turtle.forward()
  33. -- Check if there's a chest in front of it after moving forward, to refuel or offload wheat
  34. success,data = turtle.inspect()
  35. if success then
  36. print("Looking for chest, name: ", data.name)
  37. for k,v in pairs(data.state) do
  38. print("data.state." .. k, v)
  39. end
  40. for k,v in pairs(data.tags) do
  41. print("data.tags." .. k,v)
  42. end
  43. if data.tags["forge:chests"] then -- quark:birchchest is mine... has to be a better way...
  44. -- Pick up whatever's in it into slot 4
  45. turtle.select(testSlot)
  46. turtle.suck()
  47. -- See what we picked up
  48. local slotdata = turtle.getItemDetail()
  49. if slotdata ~= nil then
  50. print("Slot name: ", slotdata.name)
  51. if slotdata.name == "minecraft:wheat" then
  52. -- Put it back, and put any wheat we have in there
  53. turtle.drop()
  54. turtle.select(wheatSlot)
  55. turtle.drop()
  56. elseif slotdata.name == "minecraft:coal" then
  57. if not turtle.transferTo(fuelSlot) then
  58. turtle.drop() -- Put any leftovers back
  59. end
  60. end
  61. else
  62. -- If there was nothing in the chest, put wheat in
  63. turtle.select(wheatSlot)
  64. turtle.drop()
  65. end
  66. end
  67. -- And then if anything was in front of us, and anything was at our right
  68. -- Do a 180
  69. if hasBlockRight then
  70. turtle.turnRight()
  71. turtle.turnRight()
  72. end
  73. end
  74.  
  75. turtle.select(fuelSlot)
  76. turtle.refuel()
  77. end
  78.  
  79. -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
  80. -- We get that from data.state.age
  81.  
  82.  
  83.  
Add Comment
Please, Sign In to add comment