This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ToFran's profile picture

Rainbow Tree Farm Program [RTC]

Started by ToFran, 19 September 2014 - 11:57 PM
ToFran #1
Posted 20 September 2014 - 01:57 AM


Hi,
Here is my Rainbow Tree Chopper/Farm, a simple program to chop down a rainbow tree and/or farm it.
This tree is from an mod called Dye Trees, which is included in feed the beast latest modpacks.
This can be really useful as an gold generator in FTB.


How to Plant Rainbow Tree:
  • Place 4 (2x2) Rainbow Tree Sapling on dirt (in an clear area)
  • Let it grow naturally or use one, just one bone meal.

Note: The tree only grows during daylight, and it has an underground root.


How to chop down a tree:
  • Place the turtle on the left side of the tree (yes the tree does not have "left side"), as suggested in the image…
  • Run the program
  • Hit "1" followed by Enter
  • Wait….
  • Collect the hundreds of dropped items :)/>





How to Use the automated farm:
  • Create an item collector (exemple in the image bellow);
  • Plant the tree;
  • Place the turtle in the same spot as the simple chopper;
  • Run the program and type 2 then Enter;
  • Make sure to place saplings in the lot 15 (min 4) and dirt in the 16th slot (min1);
  • Hit enter again

Detailed Image Here

The turtle will:
  • Collect the tree;
  • (Wait 10 sec to allow items to flow)
  • Replant it;
  • Drop the wood in the chest;
  • Wait for it to grow.
And it will repeat this process until it does dot have sufficient resources.

Example of an item collector and filter:


What Are the drops?
  1. Hundreds of tree dyes;
  2. Tons minecraft vanilla dyes;
  3. Lots of apples, Cocoa Beans, Bone meal and Lapis Lazuli;
  4. Some golden apples;
  5. One or two God Apple aka Notch Apple;
How to get gold from the tree?
In FTB there is an mod called twilight forest, it adds an item called Uncrafting table, as the name suggests you can uncraft items, so by uncrafting an God apple you get 8 Gold blocks (72 Gold Ingots)!
Note you need 9 levels of experience to uncraft it.



The Program (Download):
http://pastebin.com/QBHnGps7

Code–by ToFran

local function DigAndForward(times)
times = times or 1
for i = 1,times do
turtle.dig()
turtle.forward()
end
end

local function DigDownAndForward(times)
times = times or 1
for i = 1,times do
turtle.digDown()
turtle.dig()
turtle.forward()
end
end

local function DigUpDownAndForward(times)
times = times or 1
for i = 1,times do
turtle.digUp()
turtle.digDown()
turtle.dig()
turtle.forward()
end
end


local function Leftarino()
turtle.turnLeft()
DigAndForward()
turtle.turnLeft()
end

local function Rightarino()
turtle.turnRight()
DigAndForward()
turtle.turnRight()
end

local function SpecialRightarino()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
DigUpDownAndForward()
turtle.turnRight()
DigUpDownAndForward()
end

local function clearConsole()
term.clear()
term.setCursorPos(1,1)
end
local function MineBase()
DigAndForward(2)
turtle.forward()
Rightarino()
DigDownAndForward(1)
DigUpDownAndForward(2)
DigDownAndForward(1)
Leftarino()
DigAndForward(1)
DigUpDownAndForward(4)
Rightarino()
DigAndForward(1)
DigUpDownAndForward(4)
Leftarino()
DigAndForward(1)
DigUpDownAndForward(4)
Rightarino()
DigAndForward(3)
– 2 layer
turtle.up()
turtle.up()
turtle.turnRight()
DigAndForward(2)
turtle.turnLeft()
DigAndForward(1)
Rightarino()
DigAndForward(1)
turtle.turnLeft()
DigAndForward(1)
Rightarino()
DigAndForward(1)
turtle.turnLeft()
DigAndForward(1)
Rightarino()
DigAndForward(1)
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
end

local function UpLoop(times)
times = times or 1
for i = 1,times do
turtle.digUp()
turtle.up()
turtle.dig()
end
end

local function DownLoop(times)
times = times or 1
for i = 1,times do
turtle.digDown()
turtle.down()
turtle.dig()
end
end

local function LoopDerivation()
turtle.turnLeft()
DigAndForward(3)
Rightarino()
DigAndForward(3)
end

local function MineDerivation()
turtle.digUp()
turtle.up()
LoopDerivation()
LoopDerivation()
LoopDerivation()
LoopDerivation()
end

local function GoToTheOtherSideOfTheLogOnTop()
turtle.turnRight()
DigAndForward()
turtle.turnLeft()
turtle.dig()
end

local function GoToTheOtherSideOfTheLogOnBottom()
turtle.turnLeft()
DigAndForward()
turtle.turnRight()
turtle.dig()
end


local function RemoveRootAndCreateItemCavity()
turtle.digDown()
turtle.down()
turtle.digDown()
turtle.down()
DigDownAndForward(2)
SpecialRightarino()
DigDownAndForward(2)
turtle.turnRight()
DigDownAndForward(3)
turtle.turnRight()
DigDownAndForward(3)
SpecialRightarino()
DigDownAndForward(2)
end

local function PlaceAndforward(times)
times = times or 1
for i = 1,times do
turtle.placeDown()
turtle.forward()
end
end

local function Replant()
turtle.up()
turtle.up()
turtle.turnLeft()
turtle.select(16) – Select the dirt
PlaceAndforward(2)
turtle.turnLeft()
PlaceAndforward(3)
turtle.turnLeft()
PlaceAndforward(1)
turtle.turnLeft()
PlaceAndforward(2)
turtle.turnRight()
PlaceAndforward(1)
turtle.turnRight()
PlaceAndforward(2)
turtle.turnLeft()
PlaceAndforward(1)
turtle.turnLeft()
PlaceAndforward(3)
turtle.placeDown()
– End of Placing Dirt, lets plant!
turtle.up()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.select(15) – Select The Saplings
PlaceAndforward(1)
turtle.turnRight()
PlaceAndforward(1)
turtle.turnRight()
PlaceAndforward(1)
turtle.placeDown()
end

local function GoToChest()
turtle.turnLeft()
DigAndForward(2)
turtle.turnLeft()
DigAndForward(8)
– Drop The Wood
turtle.select(1)
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
turtle.select(5)
turtle.drop() – Drop remaining dirt
turtle.select(1)
– Go to the chopping spot
turtle.turnRight()
turtle.turnRight()
DigAndForward(6)
turtle.down()
end

local function TreeCheck()
notreeWarning = 0
turtle.select(1)
while turtle.compare() do
sleep(1)
if notreeWarning==0 then
print("No tree detected, waiting…")
notreeWarning = 1
end
end
if notreeWarning==1 then
print("Detected! Chopping started.")
end
end

– UI Stuff
clearConsole()
print("Rainbow Tree Chopper by ToFran\nChoose one of the following options:\n [1] Chop down the tree.\n [2] Start the tree farm.")
local input = read()
clearConsole()

if input=="1" then – Chop down the tree.
if turtle.getFuelLevel() > 155 then
write("Fuel level is ")
write(turtle.getFuelLevel())
write("\n")
MineBase()
UpLoop(6)
MineDerivation()
UpLoop(4)
MineDerivation()
UpLoop(10)
GoToTheOtherSideOfTheLogOnTop()
DownLoop(27)
GoToTheOtherSideOfTheLogOnBottom()
UpLoop(2)
turtle.back()
else
print("Not enough fuel :(/>")
end
elseif input=="2" then
if turtle.getFuelLevel() > 200 then
print("Please place dirt on slot 16 and rainbow saplings on slot 15. \nPress enter to continue…")
local input = read()
while true do – Its an farm, so its infinite :P/>
if turtle.getItemCount(15) < 4 or turtle.getItemCount(16) < 1 then
print("Unable to continue, lack of resources\nTerminating!")
print(turtle.getItemCount(15))
print(turtle.getItemCount(16))
return
end

clearConsole()
write("Fuel level is ")
write(turtle.getFuelLevel())
write("\n")
TreeCheck() – Sleeps the program until a tree is detected
MineBase()
UpLoop(6)
MineDerivation()
UpLoop(4)
MineDerivation()
UpLoop(10)
GoToTheOtherSideOfTheLogOnTop()
DownLoop(24)
RemoveRootAndCreateItemCavity()
Replant()
GoToChest()
end
else
print("Not enough fuel :(/>")
end
end

write("Remaining fuel: ")
write(turtle.getFuelLevel())
write("\n")


–by ToFran

How to download Install and run it:
  • Make sure that your turtle is labelled;
  • do:
    
    pastebin get QBHnGps7 rtc
    
  • To run the program type rtc.
Note: In order to download the program directly to your turtle you need to have that feature enabled.
Alternatively you can place the file in your save (search the forum for more info).


What can be/ will be improved:
  • Separated chests, so the turtle can run forever, by refiling the saplings automatically;
  • Add an option to auto refuel with the collected wood, and drop only the remaining;
  • Manage an way to use bone meal in the saplings (the tree is a source of bonemeal too), but the problem is that to place bonemeal you need to be standing in a distance of 1/2 blocks;
  • Suggestions?
I hope this can be useful for someone :P/>

ToFran
Edited on 20 September 2014 - 05:16 PM
RockyPoint #2
Posted 20 September 2014 - 11:53 AM
+1 Really useful in FTB Monster Pack.
ToFran #3
Posted 20 September 2014 - 07:00 PM
+1 Really useful in FTB Monster Pack.

Thanks!