Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - --************
 - --*Print Logo*
 - --************
 - function logo()
 - shell.run('clear')
 - print "***************************************"
 - print "* Tree Farm *"
 - print "* Version 3.0 *"
 - print "* Created By: rhyser9 *"
 - print "***************************************"
 - term.setCursorPos(1,6)
 - end
 - --*****************
 - --*Terminate Error*
 - --*****************
 - function terminate()
 - sleep(1)
 - print "Terminating Program..."
 - sleep(3)
 - print "Program Terminated"
 - error()
 - end
 - --******************
 - --*Gather Materials*
 - --******************
 - logo()
 - print "Please place Saplings in Slot #1."
 - turtle.select(1)
 - while turtle.getItemCount(1) == 0 do
 - sleep(1)
 - end
 - logo()
 - print "Please place bonemeal in Slot #2."
 - turtle.select(2)
 - while turtle.getItemCount(2) == 0 do
 - sleep(1)
 - end
 - logo()
 - print "Please place a Log in Slot #15."
 - turtle.select(15)
 - while turtle.getItemCount(15) == 0 do
 - sleep(1)
 - end
 - logo()
 - print "Please place fuel in Slot #16."
 - turtle.select(16)
 - while turtle.getItemCount(16) == 0 do
 - sleep(1)
 - end
 - --*******************
 - --*Configure Program*
 - --*******************
 - logo()
 - print "Would you like to enable the Resupply function?"
 - write("(Y/N): ")
 - input = read()
 - if input == "Y" or input == "y" then
 - resupply = 1
 - print "Resupply Mode Enabled"
 - elseif input == "N" or input == "n" then
 - resupply = 0
 - print "Resupply Mode not Enabled"
 - else
 - resupplyOn = 0
 - print "Couldn't Understand Input"
 - print "Resupply Mode not Enabled"
 - end
 - sleep(2)
 - --*******************
 - --*Calculate Runtime*
 - --*******************
 - local sapling = turtle.getItemCount(1) - 1
 - local bonemeal = turtle.getItemCount(2) - 1
 - logo()
 - print "Calculating Runtime..."
 - sleep(2)
 - if sapling <= bonemeal then
 - if sapling == 0 then
 - print "Not Enough Items to Run"
 - sleep(1)
 - print "Terminating Program"
 - sleep(3)
 - print "Program Terminated"
 - error()
 - elseif sapling == 1 then
 - print "The program should run 1 time."
 - else
 - write("The program should run "..sapling.." times.\n")
 - end
 - else
 - if bonemeal == 0 then
 - print "Not Enough Items to Run"
 - sleep(1)
 - print "Terminating Program"
 - sleep(3)
 - print "Program Terminated"
 - error()
 - elseif bonemeal == 1 then
 - print "The program should run 1 time."
 - else
 - write("The program should run "..bonemeal.." times.\n")
 - end
 - end
 - for i=0,4 do
 - write("\nThe program will initiate in "..5 - i.." seconds")
 - sleep(1)
 - end
 - shell.run('clear')
 - --********
 - --*Refuel*
 - --********
 - function refuel()
 - while turtle.getFuelLevel() < 50 do
 - print " Low Fuel!"
 - print " Refueling..."
 - turtle.select(16)
 - turtle.refuel(1)
 - sleep(2)
 - if turtle.refuel() == false then
 - print " Refueling Failed!"
 - terminate()
 - else
 - print " Turtle Refueled"
 - end
 - end
 - end
 - --**********************
 - --*Plant & Grow Sapling*
 - --**********************
 - function plant()
 - print " Planting Tree..."
 - turtle.select(1)
 - turtle.place()
 - --Bonemeal
 - turtle.select(2)
 - turtle.place()
 - --Verify Process
 - turtle.select(15)
 - if turtle.compare() then
 - print " Planting Process Successful"
 - else
 - print " Planting Process Failed"
 - print " Possible Causes:"
 - print " * Saplings and Logs don't match"
 - print " * Planting Area Blocked"
 - terminate()
 - end
 - end
 - --**************
 - --*Harvest Tree*
 - --**************
 - function harvest()
 - print " Harvesting Tree..."
 - turtle.select(15)
 - while turtle.compare() == true do
 - turtle.dig()
 - turtle.digUp()
 - turtle.up()
 - end
 - while turtle.detectDown() == false do
 - turtle.down()
 - end
 - turtle.turnRight()
 - turtle.turnRight()
 - print " Harvest Completed"
 - end
 - --**********
 - --*Resupply*
 - --**********
 - function resupply()
 - local i = 0
 - --Saplings
 - turtle.suckDown()
 - --Fuel
 - turtle.turnRight()
 - turtle.suck()
 - --Bonemeal
 - turtle.turnLeft()
 - turtle.turnLeft()
 - turtle.suck()
 - --Drop Off Extras
 - turtle.turnRight()
 - while i ~= 10 do
 - turtle.select(4 + i)
 - turtle.drop()
 - i = i + 1
 - end
 - turtle.select(15)
 - turtle.drop(turtle.getItemCount(15) - 1)
 - turtle.turnLeft()
 - turtle.turnLeft()
 - end
 - --***********
 - --*Main Loop*
 - --***********
 - local resupplyOn
 - logo()
 - while turtle.getItemCount(1) > 1 and turtle.getItemCount(2) > 1 do
 - logo()
 - print "Farming Cycle Initiated"
 - refuel()
 - plant()
 - harvest()
 - if resupplyOn == 0 then
 - resupply()
 - end
 - print "Farming Cycle Completed"
 - end
 - print "Program Completed"
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment