SHOW:
|
|
- or go back to the newest paste.
| 1 | local wood, sapling = 1, 2 | |
| 2 | local treeHeight = 0 | |
| 3 | local treeCount = 0 | |
| 4 | local plantCount = 6 | |
| 5 | ||
| 6 | function tRefuel() | |
| 7 | while turtle.getFuelLevel() < 200 do | |
| 8 | turtle.select(wood) --charcol in this slot | |
| 9 | turtle.refuel(1) | |
| 10 | print("Refueled")
| |
| 11 | end | |
| 12 | print( "Fuel Level: ", turtle.getFuelLevel() ) | |
| 13 | end | |
| 14 | ||
| 15 | function tF() | |
| 16 | while not turtle.forward() do | |
| 17 | -- turtle blocked from moving forward | |
| 18 | print( "Turtle blocked from moving forward" ) | |
| 19 | sleep(3) -- wait 3 seconds to let mob move away | |
| 20 | end | |
| 21 | end | |
| 22 | ||
| 23 | function tVacume() | |
| 24 | for i = 1, 4 do | |
| 25 | turtle.turnLeft() | |
| 26 | turtle.suck() | |
| 27 | end | |
| 28 | turtle.suckUp() -- in case a sapling fell on turtle's head:D | |
| 29 | end | |
| 30 | ||
| 31 | ||
| 32 | ||
| 33 | while true do | |
| 34 | tRefuel() | |
| 35 | print( "Tree Count: ", treeCount ) | |
| 36 | -- check all trees for any that have grown | |
| 37 | for i = 1, plantCount do | |
| 38 | turtle.turnRight() | |
| 39 | turtle.select(wood) | |
| 40 | -- if the tree has grown | |
| 41 | if turtle.compare() then | |
| 42 | -- harvest the tree | |
| 43 | treeCount = treeCount + 1 | |
| 44 | while turtle.compare() do | |
| 45 | turtle.dig() | |
| 46 | if turtle.detectUp() then | |
| 47 | turtle.digUp() | |
| 48 | end | |
| 49 | turtle.up() | |
| 50 | treeHeight = treeHeight + 1 | |
| 51 | end | |
| 52 | -- return to the ground | |
| 53 | -- if blocked, dig | |
| 54 | while treeHeight > 0 do | |
| 55 | if turtle.down() then | |
| 56 | treeHeight = treeHeight - 1 | |
| 57 | else | |
| 58 | turtle.digDown() | |
| 59 | end | |
| 60 | end | |
| 61 | -- plant a new sapling | |
| 62 | turtle.select(sapling) | |
| 63 | turtle.place() | |
| 64 | else | |
| 65 | turtle.select(sapling) | |
| 66 | if not turtle.compare() then | |
| 67 | turtle.place() | |
| 68 | end | |
| 69 | end | |
| 70 | -- move to next tree location | |
| 71 | turtle.turnLeft() | |
| 72 | tVacume() | |
| 73 | tF() | |
| 74 | tVacume() | |
| 75 | tF() | |
| 76 | tVacume() | |
| 77 | tF() | |
| 78 | tVacume() | |
| 79 | tF() | |
| 80 | tVacume() | |
| 81 | end | |
| 82 | -- round the corner | |
| 83 | tF() | |
| 84 | -- dump excess items into chest if a chest is present | |
| 85 | if turtle.detect() then | |
| 86 | for i = 3, 16 do | |
| 87 | turtle.select(i) | |
| 88 | turtle.drop() | |
| 89 | end | |
| 90 | print( "Dropped off Excess Items") | |
| 91 | end | |
| 92 | turtle.turnRight() | |
| 93 | tF() | |
| 94 | tF() | |
| 95 | turtle.turnRight() | |
| 96 | tF() | |
| 97 | sleep(60) -- wait for trees to grow and saplings to fall | |
| 98 | end |