Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local component = require("component")
- local geolyzer = component.geolyzer
- local sides = require("sides")
- local controller = component.inventory_controller
- local turtle = robot
- local event = require("event")
- print("Wheat Harvester by arc13 version 1.2")
- t = geolyzer.analyze(sides.bottom)
- local bRun = true
- robot.select(1)
- local function detectWheat()
- t = geolyzer.analyze(sides.bottom)
- local oldSlot = robot.select()
- if robot.count(oldSlot) == 0 or controller.getStackInInternalSlot(oldSlot).name ~= "minecraft:wheat_seeds" then
- --print("no seed in slot "..oldSlot)
- for i = 1, robot.inventorySize() do
- if robot.count(i) > 0 then
- if controller.getStackInInternalSlot(i).name == "minecraft:wheat_seeds" then
- robot.select(i)
- break
- end
- end
- end
- end
- if t.metadata == 7 then
- robot.swingDown()
- robot.placeDown()
- robot.select(oldSlot)
- return true
- elseif t.metadata < 7 then
- for i = 1, robot.inventorySize() do
- if robot.count(i) > 0 then
- if controller.getStackInInternalSlot(i).name == "minecraft:dye" and controller.getStackInInternalSlot(i).damage == 15 then
- robot.select(i)
- t = geolyzer.analyze(sides.bottom)
- while t.metadata < 7 do
- robot.placeDown()
- t = geolyzer.analyze(sides.bottom)
- end
- robot.swingDown()
- robot.select(oldSlot)
- robot.placeDown()
- return true
- end
- end
- end
- elseif not robot.detectDown() then
- robot.placeDown()
- robot.select(oldSlot)
- return false
- else
- robot.select(oldSlot)
- return false
- end
- end
- local function dropWheat()
- for i = 1, robot.inventorySize() do
- if robot.count(i) > 0 then
- if controller.getStackInInternalSlot(i).name == "minecraft:wheat" then
- oldSlot = robot.select()
- robot.select(i)
- robot.drop()
- robot.select(oldSlot)
- elseif controller.getStackInInternalSlot(i).name == "minecraft:wheat_seeds" then
- oldSlot = robot.select()
- robot.select(i)
- robot.transferTo(1)
- robot.select(oldSlot)
- end
- end
- end
- end
- while bRun do
- if not robot.detect() then
- detectWheat()
- robot.forward()
- else
- robot.turnRight()
- detectWheat()
- robot.forward()
- c = geolyzer.analyze(sides.left)
- if c.name == "minecraft:chest" then
- robot.turnLeft()
- dropWheat()
- robot.turnRight()
- end
- robot.turnRight()
- end
- end
- print("Terminated")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement