Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fuelSlot = 1
- local seedSlot = 2
- -- Wheat has all other slots? Or just 3, idk
- local wheatSlot = 3
- local testSlot = 4
- turtle.refuel()
- while(true) do
- turtle.turnRight()
- -- Inspect the block in front of it
- local success, data = turtle.inspect()
- local hasBlockRight = success
- if success then
- -- data contains fields: name, tags, state
- print("Name: ", data.name)
- if data.name == "minecraft:wheat" then
- if data.state.age == 7 then
- -- Select the seeds to punch it
- turtle.select(seedSlot)
- turtle.attack("left") -- Do we need to stand on it and attack down? Do we need to specify "left" for attacking with seeds/hand?
- -- You think we can just turtle.place()? Try that later
- turtle.dig()
- turtle.suck()
- turtle.place()
- turtle.select(wheatSlot)
- turtle.suck()
- end
- end
- turtle.turnLeft() -- Turn back forward
- end -- If there's nothing in front of it, it can just keep going that way.
- turtle.forward()
- -- Check if there's a chest in front of it after moving forward, to refuel or offload wheat
- success,data = turtle.inspect()
- if success then
- print("Looking for chest, name: ", data.name)
- for k,v in pairs(data.state) do
- print("data.state." .. k, v)
- end
- for k,v in pairs(data.tags) do
- print("data.tags." .. k,v)
- end
- if data.tags["forge:chests"] then -- quark:birchchest is mine... has to be a better way...
- -- Pick up whatever's in it into slot 4
- turtle.select(testSlot)
- turtle.suck()
- -- See what we picked up
- local slotdata = turtle.getItemDetail()
- print("Slot name: ", slotdata.name)
- if slotdata.name == "minecraft:wheat" then
- -- Put it back, and put any wheat we have in there
- turtle.drop()
- turtle.select(wheatSlot)
- turtle.drop()
- elseif slotdata.name == "minecraft:coal" then
- if not turtle.transferTo(fuelSlot) then
- turtle.drop() -- Put any leftovers back
- end
- end
- end
- -- And then if anything was in front of us, and anything was at our right
- -- Do a 180
- if hasBlockRight then
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- turtle.select(fuelSlot)
- turtle.refuel()
- end
- -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
- -- We get that from data.state.age
Add Comment
Please, Sign In to add comment