Dimencia

testfarm5

Mar 21st, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 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. -- Put up the hoe to punch it?
  20. turtle.select(testSlot)
  21. turtle.equipLeft()
  22. turtle.attack("right") -- Do we need to stand on it and attack down? Do we need to specify "left" for attacking with seeds/hand?
  23. turtle.equipLeft()
  24. -- You think we can just turtle.place()? Try that later
  25. turtle.dig()
  26. turtle.suck()
  27. turtle.place()
  28. turtle.select(wheatSlot)
  29. turtle.suck()
  30. end
  31. end
  32. turtle.turnLeft() -- Turn back forward
  33. end -- If there's nothing in front of it, it can just keep going that way.
  34. turtle.forward()
  35. -- Check if there's a chest in front of it after moving forward, to refuel or offload wheat
  36. success,data = turtle.inspect()
  37. if success then
  38. print("Looking for chest, name: ", data.name)
  39. for k,v in pairs(data.state) do
  40. print("data.state." .. k, v)
  41. end
  42. for k,v in pairs(data.tags) do
  43. print("data.tags." .. k,v)
  44. end
  45. if data.tags["forge:chests"] then -- quark:birchchest is mine... has to be a better way...
  46. -- Pick up whatever's in it into slot 4
  47. turtle.select(testSlot)
  48. turtle.suck()
  49. -- See what we picked up
  50. local slotdata = turtle.getItemDetail()
  51. if slotdata ~= nil then
  52. print("Slot name: ", slotdata.name)
  53. if slotdata.name == "minecraft:wheat" then
  54. -- Put it back, and put any wheat we have in there
  55. turtle.drop()
  56. turtle.select(wheatSlot)
  57. turtle.drop()
  58. elseif slotdata.name == "minecraft:coal" then
  59. if not turtle.transferTo(fuelSlot) then
  60. turtle.drop() -- Put any leftovers back
  61. end
  62. end
  63. else
  64. -- If there was nothing in the chest, put wheat in
  65. turtle.select(wheatSlot)
  66. turtle.drop()
  67. end
  68. end
  69. -- And then if anything was in front of us, and anything is also at our right
  70. -- Do a 180
  71. turtle.turnRight()
  72. if turtle.detect() then
  73. turtle.turnRight()
  74. turtle.turnRight()
  75. else
  76. turtle.turnLeft() -- This feels dumb because we turn right again immediately but oh well
  77. end
  78. end
  79.  
  80. turtle.select(fuelSlot)
  81. turtle.refuel()
  82. end
  83.  
  84. -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
  85. -- We get that from data.state.age
  86.  
  87.  
  88.  
Add Comment
Please, Sign In to add comment