Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - -- Small Tree Farm Builder v0.3
 - -- BY: LazyNub
 - --
 - -- Modified version of
 - -- Robust Turtle API by SpeedR
 - -- integrated into code in v0.3
 - --
 - -- Works well with Andy Logger Deluxe Felling Turtle program
 - -- Located at: pastebin get HanjL7Mz logger
 - -- Suggest fir trees in a 4x4 formation
 - -- You will need a water bucket and 17 saplings and 17 dirt minimum
 - --
 - -- Place the mining turtle at the lower left hand corner of the
 - -- construction site you have planned. You will need an area 17x18 (Width x Length)
 - -- open to the sky or tall enough for your trees plus 6 vertical blocks.
 - --
 - -- Items needed:
 - -- Building blocks: 325 placed in first 5 slots (any solid block)
 - -- Optional Furnace: 1 Placed in Slot 15
 - -- Needed Wooden Chests: 4 Placed in Slot 14
 - -- Needed Obsidian Transport Pipe: 1 Placed in slot 12
 - -- Needed Stone Transport Pipes: 5 Placed in Slot 13
 - -- Fuel needed ~400: Placed in Slot 16 (5 coal ore)
 - -- ~7 min build time
 - --
 - local NeededBlocks = 324
 - local NeededFuel = 400
 - local blockslot = 1
 - local blockslotcur = 1
 - function checkfuellevel()
 - if turtle.getFuelLevel() >= NeededFuel then
 - print ("Plenty Fuel, Thanks!")
 - return true
 - else
 - print ("Refueling...")
 - while turtle.getFuelLevel() < NeededFuel do
 - turtle.select(16)
 - turtle.refuel(1)
 - end
 - return true
 - end
 - end
 - function selectfullslot()
 - for blockslot = blockslotcur,10 do
 - if turtle.getItemCount(blockslot) >= 1 then
 - turtle.select(blockslot)
 - blockslotcur=blockslot
 - break
 - end
 - end
 - end
 - function enoughblocks()
 - t = 0
 - for i = 1,11 do
 - t = t + turtle.getItemCount(i)
 - end
 - if t >= NeededBlocks then
 - print ("Plenty Building Blocks, Thanks!")
 - return true
 - else
 - return false
 - end
 - end
 - --[[
 - Robust Turtle API by SpeedR
 - ]]--
 - --Traveling: Goes in the direction no matter what (almost)
 - --Will not be stopped by blocks or mobs
 - function forward(l)
 - l=l or 1
 - for i=1,l do
 - local tries = 0
 - while turtle.forward() ~= true do
 - turtle.dig()
 - turtle.attack()
 - sleep(0.2)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: can't move forward.")
 - return false
 - end
 - end
 - end
 - return true
 - end
 - function up(l)
 - l=l or 1
 - for i=1,l do
 - local tries = 0
 - while turtle.up() ~= true do
 - turtle.digUp()
 - turtle.attackUp()
 - sleep(0.2)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: can't move up.")
 - return false
 - end
 - end
 - end
 - return true
 - end
 - --Turning
 - function turnAround()
 - turtle.turnRight()
 - turtle.turnRight()
 - end
 - function right()
 - turtle.turnRight()
 - end
 - function left()
 - turtle.turnLeft()
 - end
 - function goRight(l)
 - l=l or 1
 - turtle.turnRight()
 - forward(l)
 - end
 - function goLeft(l)
 - l=l or 1
 - turtle.turnLeft()
 - forward(l)
 - end
 - function strafeRight(l)
 - l=l or 1
 - goRight(l)
 - turtle.turnLeft()
 - end
 - function strafeLeft(l)
 - l=l or 1
 - goLeft(l)
 - turtle.turnRight()
 - end
 - --Digging with gravel/sand detection
 - function dig()
 - local tries = 0
 - while turtle.detect() do
 - turtle.select(11)
 - turtle.dig()
 - turtle.drop()
 - selectfullslot()
 - sleep(0.3)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: dug for too long.")
 - return false
 - end
 - end
 - return true
 - end
 - function digUp()
 - local tries = 0
 - while turtle.detectUp() do
 - turtle.select(11)
 - turtle.digUp()
 - turtle.drop()
 - selectfullslot()
 - sleep(0.3)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: dug up for too long.")
 - return false
 - end
 - end
 - return true
 - end
 - function digDown()
 - local tries = 0
 - while turtle.detectDown() do
 - turtle.select(11)
 - turtle.digDown()
 - turtle.drop()
 - selectfullslot()
 - sleep(0.3)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: dug down for too long.")
 - return false
 - end
 - end
 - return true
 - end
 - --
 - function down(l)
 - l=l or 1
 - for i=1,l do
 - local tries = 0
 - while turtle.down() ~= true do
 - turtle.digDown()
 - turtle.attackDown()
 - sleep(0.2)
 - tries = tries + 1
 - if tries>500 then
 - print("Error: can't move down.")
 - return false
 - end
 - end
 - end
 - return true
 - end
 - function back(l)
 - l=l or 1
 - for i=1,l do
 - if turtle.back() ~= true then
 - turnAround()
 - forward()
 - turnAround()
 - end
 - end
 - end
 - --Place blocks
 - --Does not place when there's already the right block.
 - function place()
 - selectfullslot()
 - if turtle.compare()== false then
 - dig()
 - turtle.place()
 - end
 - end
 - function placeUp()
 - selectfullslot()
 - if turtle.compareUp()==false then
 - digUp()
 - turtle.placeUp()
 - end
 - end
 - function placeDown()
 - selectfullslot()
 - if turtle.compareDown()==false then
 - digDown()
 - turtle.placeDown()
 - end
 - end
 - local function outOfResource()
 - print("Ran out of a resource. Block: ",blockslot , ".")
 - print("Refill, then say something to proceed.")
 - read()
 - end
 - function placeRight()
 - turtle.turnRight()
 - place()
 - turtle.turnLeft()
 - end
 - function placeLeft()
 - turtle.turnLeft()
 - place()
 - turtle.turnRight()
 - end
 - function placeBack()
 - turnAround()
 - place()
 - turnAround()
 - end
 - --place row e.g. placeRow(up, forward, 15)
 - function placeRow(placeDir, travelDir, l)
 - l=l or 1
 - for i=1,l do
 - if placeDir == "forward" then
 - place()
 - elseif placeDir == "up" then
 - placeUp()
 - elseif placeDir == "down" then
 - placeDown()
 - elseif placeDir == "right" then
 - placeRight()
 - elseif placeDir == "left" then
 - placeLeft()
 - elseif placeDir == "back" then
 - placeBack()
 - else
 - print('"', placeDir, '" is not a valid direction!')
 - return false
 - end
 - if travelDir == "forward" then
 - if i < l then
 - forward()
 - end
 - elseif travelDir == "up" then
 - up()
 - elseif travelDir == "down" then
 - down()
 - elseif travelDir == "right" then
 - strafeRight()
 - elseif travelDir == "left" then
 - strafeLeft()
 - elseif travelDir == "back" then
 - back()
 - else
 - print('"', travelDir, '" is not a valid direction!')
 - return false
 - end
 - end
 - return true
 - end
 - --[[
 - Robust Turtle API by SpeedR
 - ]]--
 - function BuildWall(h,l)
 - for lt= 1,l do
 - for ht= 1,h do
 - selectfullslot()
 - turtle.place()
 - turtle.up()
 - end
 - for i=1,h do
 - turtle.down()
 - end
 - if lt < l then
 - turtle.turnRight()
 - turtle.forward()
 - turtle.turnLeft()
 - end
 - end
 - end
 - function Buildslab(w,d)
 - -- Slab will be built lower left to upper right with finish at right bottom
 - for wt=1,w do
 - placeRow("down","forward",d)
 - if wt < w then
 - if wt%2==0 then
 - turtle.turnLeft()
 - forward()
 - turtle.turnLeft()
 - else
 - turtle.turnRight()
 - forward()
 - turtle.turnRight()
 - end
 - end
 - end
 - if w%2==0 then
 - turtle.turnLeft()
 - turtle.turnLeft()
 - else
 - back(d-1)
 - end
 - end
 - -- Main Program
 - --
 - --
 - if enoughblocks() and checkfuellevel() then
 - up()
 - Buildslab(15,8)
 - forward(8)
 - turtle.turnLeft()
 - forward(14)
 - turtle.turnRight()
 - up()
 - Buildslab(15,7)
 - strafeRight()
 - up()
 - placeRow("down","forward",8)
 - left()
 - forward()
 - placeRow("down","forward",15)
 - forward()
 - left()
 - placeRow("down","forward",8)
 - forward()
 - down()
 - placeRow("down","forward",8)
 - forward()
 - goLeft()
 - down(3)
 - for i = 1,8 do
 - placeLeft()
 - placeDown()
 - placeRight()
 - forward()
 - end
 - up()
 - for i = 1,7 do
 - placeDown()
 - placeRight()
 - forward()
 - end
 - up()
 - left()
 - placeDown()
 - forward()
 - up()
 - placeRow("down","forward",8)
 - left()
 - forward(15)
 - left()
 - forward(8)
 - down(2)
 - turtle.select(12)
 - turtle.placeDown()
 - turtle.select(13)
 - for i = 1,5 do
 - up()
 - turtle.placeDown()
 - end
 - left()
 - forward()
 - turtle.select(14)
 - turtle.placeDown()
 - forward()
 - turtle.placeDown()
 - forward(2)
 - turtle.placeDown()
 - forward()
 - turtle.placeDown()
 - back(2)
 - down()
 - turtle.select(15)
 - turtle.placeUp()
 - down(2)
 - back(2)
 - placeRow("up","forward",5)
 - place()
 - strafeRight()
 - place()
 - placeRow("up","back",5)
 - down()
 - forward(6)
 - place()
 - strafeRight()
 - up(3)
 - back(3)
 - left()
 - forward(2)
 - else
 - print("Not Enough Blocks. You need: " .. NeededBlocks)
 - end
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment