Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chests = {
- "quark:oak_chest",
- "charm:oak_chest",
- }
- fuel = {
- "minecraft:coal_block",
- "actuallyadditions:block_misc",
- "quark:charcoal_block",
- }
- function checkAge()
- isBlock, data = turtle.inspect()
- if (data['state']['age'] == 7)
- then
- isgrown = true
- elseif (data['state']['age'] ~= 7)
- then
- isgrown = false
- end
- end
- function waitForGrowth()
- checkAge()
- while isgrown == false do
- sleep(20)
- checkAge()
- end
- end
- function getFuelIndex()
- for slotNum = 1, 16, 1 do
- local Item = turtle.getItemDetail(slotNum)
- if(Item ~=nil) then
- for fuelIndex =1, #fuel, 1 do
- if(Item.name == fuel[fuelIndex]) then
- return slotNum
- end
- end
- end
- end
- end
- function refuel()
- if(turtle.getFuelLevel() < 400) then
- local Index = getFuelIndex()
- if(Index ~= nil) then
- turtle.select(Index)
- turtle.refuel(2)
- end
- end
- end
- function getPotatoIndex()
- for slotNum = 1, 16, 1 do
- local item = turtle.getItemDetail(slotNum)
- if(item ~=nil) then
- if(item["name"] == "minecraft:potato") then
- return slotNum
- end
- end
- end
- end
- function harvest()
- checkAge()
- if isgrown == true then
- turtle.dig()
- turtle.suck()
- local index = getPotatoIndex()
- turtle.select(index)
- turtle.place()
- local potatoNum = turtle.getItemCount()
- turtle.dropDown(potatoNum - 1)
- goLeft()
- elseif isgrown == false then
- goLeft()
- end
- end
- function goLeft()
- turtle.turnLeft()
- local isBlock = turtle.detect()
- if isBlock == true then
- state, tags = turtle.inspect()
- for chestIndex = 1, #chests, 1 do
- if(tags.name == chests[chestIndex]) then
- refuel()
- getFuelIndex()
- local coalBlocks = turtle.getItemCount()
- if coalBlocks <= 4 then
- turtle.suck(30)
- turtle.suck(30)
- turtle.turnLeft()
- waitForGrowth()
- elseif coalBlocks > 4 then
- turtle.turnLeft()
- waitForGrowth()
- harvest()
- end
- elseif (tags.name ~= chests[chestIndex]) == false then
- turtle.forward()
- turtle.turnRight()
- end
- end
- elseif isBlock ~= true then
- turtle.forward()
- turtle.turnRight()
- end
- end
- while true do
- harvest()
- end
Add Comment
Please, Sign In to add comment