Dimencia

testfarm99

Mar 22nd, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 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. local inferiumSlot = 5
  7.  
  8. turtle.refuel()
  9. while(true) do
  10.  
  11. turtle.turnRight()
  12. -- Inspect the block in front of it
  13. local success, data = turtle.inspect()
  14. local hasBlockRight = success
  15. if success then
  16. -- data contains fields: name, tags, state
  17. print("Name: ", data.name)
  18. -- inferium_crop
  19. if data.name == "minecraft:wheat" or data.name== "inferium_crop" then
  20. --if data.state.age == 7 then
  21. turtle.select(seedSlot)
  22. turtle.place()
  23. turtle.select(wheatSlot)
  24. turtle.suck()
  25. turtle.select(inferiumSlot)
  26. turtle.suck()
  27. turtle.select(seedSlot)
  28. turtle.suck()
  29. --end
  30. end
  31. turtle.turnLeft() -- Turn back forward
  32. end -- If there's nothing in front of it, it can just keep going that way.
  33. turtle.forward()
  34. -- Check if there's a chest in front of it after moving forward, to refuel or offload wheat
  35. success,data = turtle.inspect()
  36. if success then
  37. print("Looking for chest, name: ", data.name)
  38. for k,v in pairs(data.state) do
  39. print("data.state." .. k, v)
  40. end
  41. for k,v in pairs(data.tags) do
  42. print("data.tags." .. k,v)
  43. end
  44. if data.tags["forge:chests"] then -- quark:birchchest is mine... has to be a better way...
  45. -- Pick up whatever's in it into slot 4
  46. turtle.select(testSlot)
  47. turtle.suck()
  48. -- See what we picked up
  49. local slotdata = turtle.getItemDetail()
  50. if slotdata ~= nil then
  51. print("Slot name: ", slotdata.name)
  52. if slotdata.name == "minecraft:wheat" then
  53. -- Put it back, and put any wheat we have in there
  54. turtle.drop()
  55. turtle.select(wheatSlot)
  56. turtle.drop()
  57. elseif slotdata.name == "minecraft:coal" then
  58. if not turtle.transferTo(fuelSlot) then
  59. turtle.drop() -- Put any leftovers back
  60. end
  61. end
  62. else
  63. -- If there was nothing in the chest, put wheat and inferium in
  64. turtle.select(wheatSlot)
  65. turtle.drop()
  66. turtle.select(inferiumSlot)
  67. turtle.drop()
  68. end
  69. end
  70. -- And then if anything was in front of us, and anything is also at our right
  71. -- Do a 180
  72. turtle.turnRight()
  73. if turtle.detect() then
  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. -- After everything, check all slots... if wheat is found, try to move to wheatslot
  81. -- etc
  82.  
  83. end
  84.  
  85. -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
  86. -- We get that from data.state.age
  87.  
  88.  
  89.  
Add Comment
Please, Sign In to add comment