Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- globals
- local slot = 1
- local oak = false
- function firstrow()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- end
- function nextrow()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- end
- function tree()
- --start from previous tree
- turtle.forward()
- turtle.forward()
- -- moved to tree
- turtle.dig()
- turtle.forward()
- --Start digging tree
- for i=1,6 do
- turtle.digUp()
- turtle.up()
- end
- --Going down to ground
- for i=1,6 do
- turtle.down()
- end
- end
- function cycleSlots()
- slot = slot + 1 -- selects next slot
- if slot <= 16 then -- makes sure its not more then the slots in the turtle
- turtle.select(slot)
- oak = false
- end
- end
- function findSapling()
- local item = turtle.getItemDetail()
- if item then
- local count = item.count
- local name = item.name
- local damage = item.damage
- if name == "minecraft:sapling" and damage == 0 then
- turtle.place() -- placing sapling
- print("yes!")
- oak = true
- else
- print(slot,"is a nope ", count, " ", name, " ", damage) -- debugging
- cycleSlots()
- if slot == 16 and oak == false then
- saplings() -- goes to find more saplings from storage if found nothing in the 16 slots
- end
- end
- else
- turtle.select(slot)
- slot = slot+1
- print("changing slot to:",slot-1)
- end
- end
- function plant()
- turtle.back()
- while oak == false do
- end
- turtle.back()
- turtle.back()
- end
- function saplings()
- -- add path finding to chest for more saplings or home here
- print("No saplings in turtle :( ")
- end
- function row()
- local trees = 10
- for i=1,trees do
- tree()
- end
- for i=1,trees-1 do
- plant()
- end
- end
- -- start of program
- print("fuel level: ", turtle.getFuelLevel())
- --first row
- --firstrow()
- --turtle.forward()
- -- row 1
- --row()
- --nextrow()
- -- row 2
- --row()
- --nextrow()
- -- row 3
- --row()
- -- to home
- -- reset slot to 1
- turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement