Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function refuel()
- local level = turtle.getFuelLevel()
- if level < 25 then
- turtle.select(1)
- turtle.refuel(2)
- end
- end
- local function isLog()
- s, data = turtle.inspect()
- ret = data.name == "minecraft:spruce_log"
- print(data.name)
- print(ret)
- return ret
- end
- local function isEmpty()
- s, data = turtle.inspect()
- return data.name == nil
- end
- local function restock()
- turtle.select(2)
- local count = turtle.getItemCount(2)
- if (count < 12) then
- turtle.turnLeft()
- turtle.suck(8)
- turtle.turnRight()
- end
- turtle.select(1)
- end
- local function plant()
- refuel()
- restock()
- turtle.forward()
- turtle.select(2)
- turtle.place()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.place()
- turtle.back()
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place()
- turtle.select(1)
- end
- local function flushItems()
- count = turtle.getItemCount(4)
- if count > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- for cnt=3, 16, 1 do
- turtle.select(cnt)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- end
- end
- local function chop()
- turtle.dig()
- turtle.digUp()
- end
- local function chopDown()
- turtle.dig()
- local s, blockDown = turtle.inspectDown()
- print(blockDown.name)
- if blockDown.name == "minecraft:spruce_log" then
- turtle.digDown()
- end
- end
- local function changeRow()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- local function resetPos()
- turtle.back()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- while true do
- os.sleep(2)
- flushItems()
- if isEmpty() then
- plant()
- end
- if isLog() then
- turtle.dig()
- turtle.forward()
- while isLog() do
- refuel()
- chop()
- turtle.up()
- end
- changeRow()
- while isLog() do
- refuel()
- chopDown()
- turtle.down()
- end
- resetPos()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement