Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Pastebin code: UBF9dPVh
- --Wood-Log of the same type as the sapling, goes to slot #16
- --Saplings go to slot #15
- --Put a chest to the left of the turtle, to have the turtle drop his wood-logs
- --Put a chest on top of the turtle, to have it collect fuel (charcoal is gd, since its a tree-farm)
- --Put a chest behind it, to have it collect saplings+drop the saplings
- --If the turtle has more than 64 saplings, it will drop the saplings into the chest!
- local tArgs = {...}
- local AmountCheck = 0
- local LogCount = 0
- local LogCount2 = 0
- local RefuelAmount = 0
- shell.run("clear")
- if tArgs[1] == "info" then
- print("the same wood-log as the tree-farm's sapling")
- print("goes into slot #16, saplings #15")
- print("Press ENTER to continue reading the info!")
- check = read()
- shell.run("clear")
- print("put a chest, behind the turtle, and it will draw saplings from the chest")
- print("It will also deposit saplings, but it will try to keep 1 stack on itself")
- print("put a chest to the left of the turtle, and it will drop logs into the chest")
- print("remember to put the turtle at 2 blocks height!")
- print("Press ENTER to continue reading the info!")
- check = read()
- shell.run("clear")
- print("and a water-flow to collect extra saplings is useful")
- print("the turtle can almost keep its saplings at a stable level")
- print("the turtle will try to keep 1 stack of wood-logs on itself, at all times for fuel")
- print("put a chest above the turtle to resupply it with fuel")
- print("the turtle will try to keep atleast 10000 fuel units, per cycle!")
- print("to allow big tree-farms")
- return
- end
- if #tArgs > 5 or #tArgs < 5 then
- shell.run("clear")
- print("Arguments are:")
- print("1. <amount of space between saplings>")
- print("1. You can also write <info> as the 1. argument!")
- print("2. <amount of times to go forward and place saplings>")
- print("3. <amount of times to make rows to the side>")
- print("4. <amount of cycles> you can write a number, or <forever>")
- print("5. <amount of things to refuel, per cycle from the top chest>")
- return
- end
- if tArgs[4] == "forever" then
- AmountCheck = 1
- end
- tArgs[1] = tArgs[1] + 1
- function TopChestRefuel()
- if turtle.getFuelLevel() < 10000 then
- turtle.select(14)
- turtle.suckUp()
- while turtle.getItemCount(14) < 1 do
- shell.run("clear")
- print("Master, the chest above my head has no fuel in it!")
- turtle.suckUp()
- end
- for i = 1, tArgs[5] do
- turtle.refuel(1)
- RefuelAmount = RefuelAmount+1
- if RefuelAmount == 64 then
- RefuelAmount = 0
- turtle.select(14)
- turtle.suckUp()
- while turtle.getItemCount(14) < 1 do
- shell.run("clear")
- print("Master, the chest above my head has no fuel in it!")
- turtle.suckUp()
- end
- end
- end
- end
- turtle.select(14)
- turtle.dropUp()
- turtle.select(1)
- end
- function LogChestDeposit()
- ItemSlot = 0
- turtle.turnLeft()
- if turtle.getItemCount(16) > 1 then
- LogCount = turtle.getItemCount(16)
- LogCount2 = LogCount-1
- turtle.select(16)
- turtle.drop(LogCount)
- end
- for i = 1, 14 do
- ItemSlot = ItemSlot+1
- if turtle.getItemCount(ItemSlot) > 0 then
- turtle.select(16)
- if turtle.compareTo(ItemSlot) == true then
- turtle.select(ItemSlot)
- turtle.transferTo(1)
- end
- end
- end
- ItemSlot = 1
- for i = 1, 13 do
- ItemSlot = ItemSlot+1
- if turtle.getItemCount(ItemSlot) > 0 then
- turtle.select(16)
- if turtle.compareTo(ItemSlot) == true then
- turtle.select(ItemSlot)
- if turtle.detect() == true then
- turtle.drop()
- end
- end
- end
- end
- turtle.turnRight()
- end
- function SaplingChestDraw()
- if turtle.getItemCount(15) > 0 then
- turtle.turnRight()
- turtle.turnRight()
- if turtle.detect() == true then
- turtle.suck()
- ItemSlot = 0
- for i = 1, 14 do
- ItemSlot = ItemSlot + 1
- if turtle.getItemCount(ItemSlot) > 0 then
- turtle.select(ItemSlot)
- if turtle.compareTo(15) == true then
- turtle.transferTo(15)
- end
- end
- end
- ItemSlot = 0
- for i = 1, 14 do
- ItemSlot = ItemSlot + 1
- if turtle.getItemCount(ItemSlot) > 0 then
- turtle.select(ItemSlot)
- if turtle.compareTo(15) == true then
- turtle.drop()
- end
- end
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- function CheckRefuel()
- while turtle.getFuelLevel() == 0 do
- ItemSlot = 0
- FuelCheck = 0
- shell.run("clear")
- print("I am out of fuel, my Master!")
- while FuelCheck == 0 do
- ItemSlot = ItemSlot+1
- sleep(0.4)
- if turtle.getItemCount(ItemSlot) > 0 then
- turtle.select(ItemSlot)
- if turtle.refuel(1) == true then
- FuelCheck = 1
- shell.run("clear")
- end
- end
- if ItemSlot == 14 then
- ItemSlot = 0
- end
- end
- end
- end
- function MoveBack()
- CheckRefuel()
- turtle.suckDown()
- if turtle.back() == false then
- turtle.turnRight()
- turtle.turnRight()
- while turtle.forward() == false do
- turtle.select(16)
- if turtle.compare() == true then
- OakTreeCut()
- else
- turtle.dig()
- CheckRefuel()
- turtle.attack()
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- CheckRefuel()
- end
- end
- function OakSaplingPlace()
- for i = 1, tArgs[1] do
- CheckRefuel()
- turtle.suckDown()
- while turtle.forward() == false do
- turtle.select(16)
- if turtle.compare() == true then
- OakTreeCut()
- else
- turtle.dig()
- CheckRefuel()
- turtle.attack()
- end
- end
- end
- if turtle.detectDown() == false then
- turtle.select(15)
- while turtle.placeDown() == false do
- if turtle.getItemCount(15) == 0 then
- shell.run("clear")
- print("I am out of saplings Master!")
- sleep(5)
- end
- end
- end
- end
- function OakTreeCut()
- turtle.select(1)
- heightCheck = 0
- turtle.dig()
- CheckRefuel()
- turtle.suckDown()
- while turtle.forward() == false do
- CheckRefuel()
- turtle.attack()
- end
- while turtle.detectUp() do
- heightCheck = heightCheck+1
- turtle.select(1)
- turtle.digUp()
- CheckRefuel()
- while turtle.up() == false do
- CheckRefuel()
- turtle.attackUp()
- end
- turtle.select(15)
- for i = 1, 4 do
- turtle.turnRight()
- turtle.dig()
- end
- end
- for i = 1, heightCheck do
- CheckRefuel()
- while turtle.down() == false do
- CheckRefuel()
- turtle.attackDown()
- end
- end
- turtle.suckDown()
- turtle.select(1)
- turtle.digDown()
- turtle.select(15)
- if turtle.detectDown() == false then
- turtle.select(15)
- while turtle.placeDown() == false do
- if turtle.getItemCount(15) < 0 then
- print("I am out of saplings Master!")
- sleep(5)
- end
- end
- end
- MoveBack()
- end
- function OakFarm()
- for i = 1, tArgs[2] do
- OakSaplingPlace()
- end
- for i = 1, tArgs[1] do
- for i = 1, tArgs[2] do
- MoveBack()
- end
- end
- turtle.turnRight()
- for i = 1, tArgs[3] do
- OakSaplingPlace()
- turtle.turnLeft()
- for i = 1, tArgs[2] do
- OakSaplingPlace()
- end
- for i = 1, tArgs[1] do
- for i = 1, tArgs[2] do
- MoveBack()
- end
- end
- turtle.turnRight()
- end
- for i = 1, tArgs[1] do
- for i = 1, tArgs[3] do
- MoveBack()
- end
- end
- turtle.turnLeft()
- SaplingChestDraw()
- LogChestDeposit()
- TopChestRefuel()
- shell.run("clear")
- print("Resting for 150 seconds!")
- sleep(150)
- end
- SaplingChestDraw()
- LogChestDeposit()
- TopChestRefuel()
- if AmountCheck == 1 then
- while true do
- OakFarm()
- end
- else
- AmountCheck = tArgs[4]
- for i = 1, AmountCheck do
- OakFarm()
- end
- shell.run("clear")
- print("I am done my Master!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement