Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --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.up()
- print("Sleeping to allow items to flow.")
- clearConsole()
- sleep(10)
- turtle.down()
- --
- 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(10)
- -- 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(8)
- 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
Advertisement
Add Comment
Please, Sign In to add comment