Dimencia

Testfarm3

Mar 21st, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 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.             print("Slot name: ", slotdata.name)
  50.             if slotdata.name == "minecraft:wheat" then
  51.                 -- Put it back, and put any wheat we have in there
  52.                 turtle.drop()
  53.                 turtle.select(wheatSlot)
  54.                 turtle.drop()
  55.             elseif slotdata.name == "minecraft:coal" then
  56.                 if not turtle.transferTo(fuelSlot) then
  57.                     turtle.drop() -- Put any leftovers back
  58.                 end
  59.             end
  60.         end
  61.         -- And then if anything was in front of us, and anything was at our right
  62.         -- Do a 180
  63.         if hasBlockRight then
  64.             turtle.turnRight()
  65.             turtle.turnRight()
  66.         end
  67.     end
  68.    
  69.     turtle.select(fuelSlot)
  70.     turtle.refuel()
  71. end
  72.  
  73. -- For wheat, an age of 7 is what we want.  Name is "minecraft:wheat"
  74. -- We get that from data.state.age
  75.  
  76.  
  77.  
Add Comment
Please, Sign In to add comment