Created
May 27, 2013 14:32
-
-
Save tomjn/5657380 to your computer and use it in GitHub Desktop.
Computercraft tree farm chops down and grows a tree given saplings and bonemeal, place a chest underneath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local slots ={} | |
| function plantTree() | |
| turtle.select(1) | |
| turtle.place() | |
| end | |
| function chopTree() | |
| turtle.select(4) | |
| turtle.dig() | |
| turtle.forward() | |
| while turtle.detectUp() do | |
| turtle.digUp() | |
| turtle.up() | |
| end | |
| while not turtle.detectDown() do | |
| turtle.down() | |
| end | |
| turtle.back() | |
| end | |
| function hasTreeGrown() | |
| turtle.select(3) | |
| return turtle.compare() | |
| end | |
| function bonemealTree() | |
| turtle.select(2) | |
| turtle.place() | |
| end | |
| function dropOffResources() | |
| for i=4, 16, 1 do | |
| turtle.select( i ) | |
| turtle.dropDown( 64 ) | |
| end | |
| end | |
| function checkSlot( slot ) | |
| if turtle.getItemCount(2) == 0 then | |
| if slots[ slot ] == true then | |
| print( "Slot " + slot + " empty" ) | |
| slots[ slot ] = false | |
| end | |
| else | |
| slots[ slot ] = true | |
| end | |
| end | |
| while true do | |
| if hasTreeGrown() then | |
| chopTree() | |
| dropOffResources() | |
| else | |
| plantTree() | |
| bonemealTree() | |
| end | |
| sleep(1) | |
| checkSlot( 1 ) | |
| checkSlot( 2 ) | |
| checkSlot( 3 ) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment