Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Turtle planter for dye saplings
- --
- -- Dye sapling have two major problems wich make them hard to farm:
- -- * Dye sapling don't work with MFR planter and Multifarm.
- -- * Dye saplings produce blood wood wich don't work properly with
- -- MFR harvester.
- --
- -- This program plant the given sapling every two blocks in a square shape,
- -- and harvest blood wood when the turtle are in front of it.
- --
- -- HOWTO USE
- -- ---------
- -- The *entire inventory* must be filled with sapling, exepted the last
- -- slot, wich must contain at least one blood wood log.
- --
- -- NOTES
- -- -----
- -- The turtle expect blood wood to grow in a 3x3 square, wich seems
- -- to be the case with dye sapling. It also expect that the blood
- -- wood tree begin to diverge in a 3x3 shape two blocks above from
- -- the floor. Again, it seems to be the case.
- --
- local WIDTH = 5
- local HEIGHT = 5
- local slot = 2
- turtle.forceForward = function()
- repeat until turtle.forward()
- end
- turtle.forceForwardAndDig = function()
- while not turtle.forward() do turtle.dig() end
- end
- turtle.forceUpAndDig = function()
- while not turtle.up() do turtle.digUp() end
- end
- turtle.forceDownAndDig = function()
- while not turtle.down() do turtle.digDown() end
- end
- local isBloodTree = function(compareFunc)
- local ret = false
- turtle.select(1)
- ret = compareFunc()
- turtle.select(slot)
- return ret
- end
- local break_blood_tree = function()
- if isBloodTree(turtle.compareUp) then
- turtle.forceUpAndDig()
- -- Break the whole 3x3x1 space
- turtle.forceForwardAndDig()
- turtle.turnLeft()
- turtle.forceForwardAndDig()
- for i = 1, 3 do
- turtle.turnLeft()
- turtle.forceForwardAndDig()
- turtle.forceForwardAndDig()
- end
- turtle.turnLeft()
- turtle.forceForwardAndDig()
- turtle.turnLeft()
- turtle.forceForwardAndDig()
- -- Make the turtle facing at the same direction as the begining
- turtle.turnLeft()
- turtle.turnLeft()
- break_blood_tree()
- turtle.forceDownAndDig()
- end
- end
- turtle.plant = function()
- if turtle.getItemCount() == 0 then
- if slot > 16 then
- return
- end
- slot = slot + 1
- turtle.select(slot)
- end
- -- In some rare case a block may prevent the turtle
- -- planting, remove it. Don't insist on failure.
- if not turtle.compare() then
- turtle.dig()
- end
- turtle.placeDown()
- end
- turtle.plantAndForward = function()
- turtle.plant()
- turtle.forceForward()
- if isBloodTree(turtle.compare) then
- turtle.forceForwardAndDig()
- break_blood_tree()
- else
- turtle.forceForward()
- end
- end
- turtle.select(slot)
- while slot <= 16 do
- for i = 1, WIDTH do
- for j = 1, HEIGHT - 1 do
- turtle.plantAndForward()
- end
- -- Last col have a special case for the finish since the
- -- turtle must move back to the starting position at the
- -- end of the col
- if i == WIDTH then
- turtle.plant()
- else
- if i % 2 == 0 then
- turtle.turnLeft()
- turtle.plantAndForward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.plantAndForward()
- turtle.turnRight()
- end
- end
- end
- -- Move back to the starting position
- turtle.forceForward()
- if WIDTH % 2 == 0 then
- turtle.turnRight()
- for i = 1, WIDTH - 1 do
- turtle.forceForward()
- turtle.forceForward()
- end
- turtle.turnRight()
- turtle.forceForward()
- else
- turtle.turnLeft()
- for i = 1, WIDTH - 1 do
- turtle.forceForward()
- turtle.forceForward()
- end
- turtle.forceForward()
- turtle.turnLeft()
- turtle.forceForward()
- for i = 1, HEIGHT - 1 do
- turtle.forceForward()
- turtle.forceForward()
- end
- turtle.turnLeft()
- turtle.forceForward()
- turtle.turnLeft()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement