Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*****************
- --*****************
- --** Tree Farm **
- --** Created By: **
- --** rhyser9 **
- --*****************
- --*****************
- local sapling
- local bonemeal
- --******************
- --*Gather Materials*
- --******************
- shell.run('clear')
- print "Thank you for using this tree farm."
- print "Please place saplings in Slot #1."
- turtle.select(1)
- while turtle.getItemCount(1) == 0 do
- sleep(1)
- end
- shell.run('clear')
- print "Thank you for using this tree farm."
- print "Please place bonemeal in Slot #2."
- turtle.select(2)
- while turtle.getItemCount(2) == 0 do
- sleep(1)
- end
- shell.run('clear')
- print "Thank you for using this tree farm."
- print "Please place a log of the tree your farming in Slot #15."
- turtle.select(15)
- while turtle.getItemCount(15) == 0 do
- sleep(1)
- end
- shell.run('clear')
- print "Thank you for using this tree farm."
- print "Please place some fuel in Slot #16."
- turtle.select(16)
- while turtle.getItemCount(16) == 0 do
- sleep(1)
- end
- shell.run('clear')
- print "All Materials Recieved"
- --*******************
- --*Calculate runtime*
- --*******************
- sapling = turtle.getItemCount(1) - 1
- bonemeal = turtle.getItemCount(2) - 1
- sleep(1)
- if sapling <= bonemeal then
- if sapling == 1 then
- print "The program should run 1 time."
- elseif sapling == 0 then
- print "Not Enough Items to Run"
- sleep(1)
- print "Terminating Program"
- sleep(3)
- print "Program Terminated"
- error()
- else
- write("The program should run "..sapling.." times.\n")
- end
- else
- if bonemeal == 1 then
- print "The program should run 1 time."
- elseif bonemeal == 0 then
- print "Not Enough Items to Run"
- sleep(1)
- print "Terminating Program"
- sleep(3)
- print "Program Terminated"
- error()
- 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')
- --**********************
- --*Plant & Grow Sapling*
- --**********************
- function plant()
- turtle.select(1)
- turtle.place()
- turtle.select(2)
- turtle.place()
- 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"
- print "Terminating Program"
- sleep(3)
- print "Program Terminated"
- error()
- end
- end
- --**************
- --*Harvest Tree*
- --**************
- function harvest()
- print " Initiating Harvest"
- select(15)
- while turtle.compare() == true do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- while turtle.detectDown() == false do
- turtle.down()
- end
- print " Harvest Completed"
- end
- --********
- --*Refuel*
- --********
- function refuel()
- while turtle.getFuelLevel() < 20 do
- print "Low Fuel"
- print "Attempting to Refuel"
- turtle.select(16)
- turtle.refuel(1)
- if turtle.refuel() == false then
- print "Couldn't Refuel"
- print "Terminating Program"
- sleep(2)
- print "Program Terminated"
- error()
- end
- end
- end
- --***********
- --*Main Loop*
- --***********
- while turtle.getItemCount(1) > 1 do
- if turtle.getItemCount(2) > 1 then
- print "\nInitiating Farming Cycle"
- refuel()
- plant()
- harvest()
- print "Farming Cycle Completed"
- else
- print "Program Completed"
- error()
- end
- end
- print "Program Completed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement