Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function f(loc)
- while not turtle[loc]() do
- sleep(0.5)
- end
- end
- function up() f("up") end
- function down() f("down") end
- function fw() f("forward") end
- function back() f("back") end
- function l() f("turnLeft") end
- function r() f("turnRight") end
- function d() turtle.dig() end
- function du() turtle.digUp() end
- function dd() turtle.digDown() end
- function c(x)
- for i=1,x do d() fw() du() dd() end
- end
- function makeTree()
- if turtle.getItemCount(1)==0 then
- print("Not enough Saplings.")
- return
- end
- if turtle.getItemCount(2)==0 then
- print("Not enough BoneMeal.")
- return
- end
- turtle.select(1)
- turtle.place()
- sleep(1)
- turtle.select(2)
- turtle.place()
- sleep(1)
- end
- function resetPos()
- print("Resetting position.")
- sleep(2)
- r=0
- while r==0 do
- turtle.down()
- if turtle.detectDown()==true then
- r=1
- end
- end
- turtle.back()
- end
- --function cutTree()
- -- sleep(2)
- --print("Cutting Tree.")
- -- sleep(2)
- -- turtle.dig()
- -- turtle.forward()
- -- y=1
- -- while y==1 do
- -- turtle.digUp()
- -- turtle.up()
- -- if turtle.detectUp()==false then
- -- y=0
- -- end
- -- end
- --
- --resetPos()
- --end
- function cutTree()
- print("tree cut")
- hi = 0
- while not turtle.detectUp() do
- up() hi=hi+1
- end
- du() up() du() up() du() l() l()
- c(1) r() c(2) r() c(4) r() c(4) r()
- c(4) r() c(1) r() c(3) l() c(2) l()
- c(2) back() l() c(1) l() down()
- for r=1,hi do dd() down() end
- dd() back()
- down() down()
- print(hi)
- end
- function checkMats()
- -- Checking saplings slot
- print("Checking for mats.")
- sleep(2)
- if turtle.getItemCount(1)==0 then
- print("Not enough Saplings.")
- s=1
- turtle.turnLeft()
- turtle.select(1)
- turtle.suck()
- turtle.turnRight()
- if turtle.getItemCount(1)>0 then
- s=0
- end
- end
- -- Checking bonemeal slot
- if turtle.getItemCount(2)==0 then
- print("Not enough bonemeal.")
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.suck()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- function checkStop()
- if s==0 then
- shell.exit()
- end
- end
- function ConsolidateMats()
- turtle.turnLeft()
- print("Consolidating saplings.")
- for i=3,15 do
- turtle.select(i)
- if turtle.compareTo(1) then -- It's a sapling not in slot one
- turtle.drop() -- put it in the chest to our left
- end
- end
- turtle.turnRight()
- print("Sending all other mats to processing.")
- sleep(2)
- for i=3,15 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- while true do
- makeTree()
- checkMats()
- cutTree()
- ConsolidateMats()
- checkStop()
- end
Advertisement
Add Comment
Please, Sign In to add comment