Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x,y,z = 0,0,0
- function moveUp()
- if turtle.up() then
- z = z + 1
- return true
- end
- end
- function moveDown()
- if turtle.down() then
- z = z - 1
- return true
- end
- end
- function moveFor()
- if turtle.forward() then
- x = x + 1
- return true
- end
- end
- function moveBack()
- if turtle.back() then
- x = x - 1
- return true
- end
- end
- function moveRight()
- turtle.turnRight()
- turtle.dig()
- if turtle.forward() then
- y = y + 1
- turtle.turnLeft()
- return true
- else
- turtle.turnLeft()
- return false
- end
- end
- function moveLeft()
- turtle.turnLeft()
- turtle.dig()
- if turtle.forward() then
- y = y - 1
- turtle.turnRight()
- return true
- else
- turtle.turnRight()
- return false
- end
- end
- function mineUp()
- turtle.dig()
- turtle.digUp()
- moveUp()
- end
- function mineDown()
- turtle.dig()
- turtle.digDown()
- moveDown()
- end
- function mineFor()
- turtle.dig()
- moveFor()
- end
- function dropOff()
- print("Dropping off items..")
- turtle.turnRight()
- turtle.turnRight()
- for i=2,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function waitGrow()
- print("Waiting for grow..")
- turtle.select(1)
- while turtle.compare() do
- os.sleep(10)
- end
- print("Tree grew!")
- return true
- end
- function placeSapling()
- turtle.select(1)
- if turtle.getItemCount(1) < 4 then
- print("Ran out of saplings.")
- return false
- else
- print("Planting new tree.")
- end
- moveFor()
- turtle.place()
- moveRight()
- turtle.place()
- moveBack()
- turtle.place()
- moveLeft()
- turtle.place()
- return true
- end
- function chopTree()
- print("Chopping tree.")
- mineFor()
- while turtle.detect() do
- mineUp()
- end
- moveRight()
- while z ~= 0 do
- mineDown()
- end
- turtle.dig()
- moveBack()
- moveLeft()
- end
- function farm()
- if not placeSapling() then
- return false
- end
- waitGrow()
- chopTree()
- dropOff()
- if x ~= 0 or y ~= 0 or z ~= 0 then
- return false
- end
- os.sleep(1)
- return true
- end
- while true do
- if not farm() then
- print("Something went wrong.")
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment