Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local height = 0
- local time = os.clock()
- local fuelNeeded = false
- local function forward()
- while not turtle.forward() do
- turtle.attack()
- turtle.dig()
- end
- return true
- end
- local function down()
- while not turtle.down() do
- turtle.attackDown()
- turtle.digDown()
- end
- return true
- end
- local function up()
- while not turtle.up() do
- turtle.attackUp()
- turtle.digUp()
- end
- return true
- end
- local function checkFuel()
- if turtle.getFuelLevel() <= 200 then
- fuelNeeded = true
- elseif turtle.getFuelLevel() <= 10 then
- error("Bitte manuel auftanken.")
- else
- fuelNeeded = false
- end
- end
- local function checkSuck()
- if os.clock() >= (time + 200) then
- down()
- down()
- time = os.clock()
- turtle.suckDown()
- up()
- up()
- end
- end
- local function checkSlots(sCount)
- if turtle.getItemCount(1) < sCount then
- print("Zu wenige Saplings in Slot 1, bitte mindestens ", sCount, " einfuellen und Taste druecken.")
- os.pullEvent("key")
- end
- end
- local function drop()
- down()
- down()
- down()
- for i=2, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- up()
- turtle.suckDown()
- time = os.clock()
- up()
- up()
- checkFuel()
- end
- local function harvest()
- checkSlots(5)
- turtle.select(2)
- turtle.down()
- turtle.dig()
- forward()
- while turtle.detectUp() do
- turtle.dig()
- turtle.digUp()
- if up() then
- height = height + 1
- end
- end
- turtle.dig()
- turtle.turnLeft()
- turtle.dig()
- forward()
- turtle.turnRight()
- while height > 0 do
- turtle.dig()
- turtle.digDown()
- if down() then
- height = height - 1
- end
- end
- turtle.dig()
- checkSlots(5)
- turtle.select(1)
- turtle.dig()
- turtle.place()
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- turtle.dig()
- turtle.place()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- checkFuel()
- if fuelNeeded then
- for i=2, 16 do
- turtle.select(i)
- turtle.refuel()
- end
- turtle.select(1)
- checkFuel()
- end
- up()
- drop()
- end
- local function place()
- checkSlots(5)
- turtle.select(1)
- forward()
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- turtle.dig()
- turtle.place()
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- turtle.dig()
- turtle.place()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- end
- local function start()
- checkSlots(17)
- checkSuck()
- checkFuel()
- for i = 1, 4 do
- place()
- turtle.turnLeft()
- end
- up()
- checkFuel()
- end
- local function wait()
- checkSlots(5)
- select(1)
- while not turtle.detect() do
- turtle.turnLeft()
- sleep(1)
- checkSuck()
- end
- end
- ----------------------------------------------
- start()
- while true do
- wait()
- harvest()
- end
Advertisement
Add Comment
Please, Sign In to add comment