Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- run = true
- 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.suck()
- 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.inspect()
- while true do
- if (data["state"]["age"] == 7) then
- return true
- else
- return false
- end
- end
- end
- function boundaryDetect()
- local isBlock, data = turtle.inspectDown()
- while true do
- if isBlock then
- if data["name"] == "minecraft:planks" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- end
- function selectNext()
- local wheatSeedIndex = getItemIndex("minecraft:wheat_seeds")
- fuelCheck()
- turtle.turnRight()
- turtle.forward()
- blockCount = blockCount + 1
- turtle.turnLeft()
- if boundaryDetect() then
- if fuelCheck() == false then
- turtle.suckUp()
- fuelCheck()
- end
- startOver()
- end
- end
- function harvest()
- while true do
- local wheatSeedIndex = getItemIndex("minecraft:wheat_seeds")
- local boneMealIndex = getItemIndex("minecraft:bone_meal")
- if turtle.inspect() == false then
- turtle.select(wheatSeedIndex)
- turtle.place()
- if boneMealIndex ~= nil then
- turtle.select(boneMealIndex)
- repeat
- turtle.place()
- until growCheck() or boneMealIndex == nil
- end
- selectNext()
- elseif (growCheck()) then
- turtle.dig()
- grab()
- turtle.select(wheatSeedIndex)
- turtle.place()
- selectNext()
- elseif boneMealIndex ~= nil then
- turtle.select(boneMealIndex)
- repeat
- turtle.place()
- until growCheck() or boneMealIndex == nil
- else
- selectNext()
- end
- end
- end
- function startOver()
- local wheatIndex = getItemIndex("minecraft:wheat")
- turtle.turnLeft()
- for i = 1, blockCount, 1 do
- turtle.forward()
- fuelCheck()
- end
- if wheatIndex ~= nil then
- while true do
- turtle.select(wheatIndex)
- turtle.drop(turtle.getItemCount(wheatIndex))
- if turtle.getItemCount(wheatIndex) == 0 then
- break
- end
- end
- end
- turtle.turnRight()
- blockCount = 0
- end
- harvest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement