Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- made by Punio (ironblocks.de)
- local mainSteps = 2
- local mainTimer = 30
- local woolSlot = 16
- local chestSlot = 15
- local woodSlot = 14
- local saplingSlot = 13
- local checkSide = false
- local turned = false
- -- functions
- function message(msg)
- term.clear()
- term.setCursorPos(1,1)
- print(msg)
- end
- function harvest()
- while not turtle.forward() do
- while not turtle.dig() and turtle.detect() do
- turtle.attack()
- sleep(.1)
- end
- end
- moved = 0
- while turtle.detectUp() do
- while not turtle.up() do
- while not turtle.digUp() and turtle.detectUp() do
- turtle.attackUp()
- sleep(.1)
- end
- end
- moved = moved + 1
- end
- while moved > 0 do
- if checkSide then
- for i = 1,4 do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.turnLeft()
- end
- end
- while not turtle.down() do
- turtle.attackDown()
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- moved = moved - 1
- end
- while not turtle.back() do
- message("cant move back!")
- sleep(.1)
- end
- end
- function plant()
- while not (turtle.getItemCount(saplingSlot) > 1) do
- message("pls refill sapling!")
- sleep(.1)
- end
- turtle.select(saplingSlot)
- if not turtle.compare() and not turtle.detect() then
- while not turtle.place() do
- message("cant place sapling!")
- sleep(.1)
- end
- end
- end
- function check()
- turtle.select(chestSlot)
- if not turtle.compare() then
- turtle.turnLeft()
- if turtle.detect() then
- turtle.select(woodSlot)
- if turtle.compare() then
- harvest()
- end
- end
- plant()
- turtle.turnRight()
- end
- end
- function turn()
- turtle.turnLeft()
- turtle.turnLeft()
- turned = not turned
- end
- function move(steps)
- for i = 1, steps do
- turtle.select(woolSlot)
- if not turtle.compareDown() or turned then
- while not turtle.forward() do
- turtle.attack()
- sleep(.1)
- end
- else
- break
- end
- end
- turtle.select(woolSlot)
- return not turtle.compareDown()
- end
- function drop()
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- if i ~= woolSlot and i ~= woodSlot and i ~= chestSlot then
- if i ~= saplingSlot then
- while not turtle.drop() do
- message("no more space in chest!")
- sleep(.1)
- end
- end
- else
- if turtle.getItemCount(i) > 1 then
- while not turtle.drop(turtle.getItemCount(i) - 1) do
- message("no more space in chest!")
- sleep(.1)
- end
- end
- end
- end
- end
- end
- function wait(timer)
- while timer > 0 do
- message("wait " .. timer .."sec")
- sleep(1)
- timer = timer - 1
- end
- end
- -- main loop
- while true do
- if turtle.getItemCount(woolSlot) > 0 and turtle.getItemCount(woodSlot) > 0 and turtle.getItemCount(chestSlot) > 0 then
- turtle.select(chestSlot)
- if turtle.compare() then
- drop()
- turn()
- wait(mainTimer)
- else
- if move(mainSteps) then
- check()
- else
- turn()
- end
- end
- else
- message("pls fill needed items in slots")
- end
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement