Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- blockCount = 0
- SLOT_COUNT = 16
- function getItemIndex(itemName)
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if (item ~= nil) then
- if(item["name"] ==itemName) then
- return slot
- end
- end
- end
- end
- function grab()
- for i = 1, 6, 1 do
- turtle.suckDown()
- end
- end
- function fuelCheck()
- local coalIndex = getItemIndex("minecraft:coal")
- if turtle.getFuelLevel() < 100 then
- if coalIndex ~= nil then
- turtle.select(coalIndex)
- turtle.refuel()
- else
- return false
- end
- end
- end
- function growCheck()
- local isBlock, data = turtle.inspectDown()
- while true do
- if isBlock then
- if (data["state"]["age"] == 7) then
- return true
- else
- return false
- end
- end
- end
- end
- function plantDetect()
- local isBlock, data = turtle.inspectDown()
- wheatSeedIndex = getItemIndex("minecraft:wheat_seeds")
- turtle.select(wheatSeedIndex)
- if turtle.placeDown() == false then
- if turtle.inspectDown() == false then
- return true
- else
- return false
- end
- else
- return true
- end
- end
- function selectNext()
- local wheatSeedIndex = getItemIndex("minecraft:wheat_seeds")
- local coalIndex = getItemIndex("minecraft:coal")
- fuelCheck()
- turtle.forward()
- if plantDetect() then
- if fuelCheck() == false then
- turtle.suckUp()
- fuelCheck()
- end
- turnAround()
- end
- end
- function harvest()
- while true do
- local wheatSeedIndex = getItemIndex("minecraft:wheat_seeds")
- local boneMealIndex = getItemIndex("minecraft:bone_meal")
- if turtle.inspectDown() == false then
- turtle.select(wheatSeedIndex)
- turtle.placeDown()
- if boneMealIndex ~= nil then
- turtle.select(boneMealIndex)
- repeat
- turtle.placeDown()
- until growCheck() or boneMealIndex == nil
- end
- elseif (growCheck()) then
- turtle.digDown()
- grab()
- turtle.select(wheatSeedIndex)
- turtle.placeDown()
- end
- if plantDetect() == false and growCheck() == false then
- if boneMealIndex ~= nil then
- turtle.select(boneMealIndex)
- repeat
- turtle.placeDown()
- until growCheck() or boneMealIndex == nil
- end
- end
- selectNext()
- end
- end
- function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- while true do
- harvest()
- end
Add Comment
Please, Sign In to add comment