SHOW:
|
|
- or go back to the newest paste.
1 | - | --[[ Running this script on a turtle with saplings in slot 1, bone-meal in slot 2 and coal in slot 16 and a chest behind the turtle for the wood drop off point will create an automatic tree farm. combining this with a chest to the left of the turtle for sapling replenishment and chest to the right for coal replenishment will ensure a long running automated process.]] |
1 | + | --[[ Running this script on a turtle with saplings in slot 1, Wood in slot 2 and a chest behind the turtle for the wood drop off point will create an automatic tree farm. combining this with a chest to the left of the turtle for sapling replenishment and chest to the right for coal replenishment will ensure a long running automated process.]] |
2 | ||
3 | -- This function lays saplings and applies bone-meal | |
4 | function plant() | |
5 | turtle.select(1) --selects sapling | |
6 | turtle.place() --places sapling | |
7 | - | turtle.select(2) --selects bone-meal |
7 | + | |
8 | - | turtle.place() --fertilizes sapling |
8 | + | |
9 | ||
10 | -- This function cuts a column directly above the turtle and then returns to ground level | |
11 | function column() | |
12 | - | -- This function checks fuel level and refuels |
12 | + | |
13 | - | function fuel() |
13 | + | |
14 | - | if turtle.getFuelLevel() < 50 then --checks fuel level and refuels |
14 | + | |
15 | - | turtle.select(16) |
15 | + | |
16 | - | turtle.refuel(5) --picks up any saplings that have fallen |
16 | + | |
17 | while turtle.detectDown() == false do -- return to ground level | |
18 | - | print( turtle.getFuelLevel() .. " fuel left.") --displays fuel level to user |
18 | + | |
19 | turtle.suck() --picks up any saplings that have fallen | |
20 | end | |
21 | end | |
22 | ||
23 | -- This function moves from start position, runs column and returns to start position | |
24 | function fell() | |
25 | turtle.dig() --breaks bottom block of tree | |
26 | turtle.forward() --move into gap | |
27 | column() --run column function | |
28 | turtle.turnRight() --return to start | |
29 | turtle.turnRight() | |
30 | turtle.forward() | |
31 | end | |
32 | ||
33 | -- This function empties all collected wood into chest, checks sapling and fuel supplies and restocks | |
34 | function empty() | |
35 | for j = 3, 16 do -- empty slots 3 to 16 into chest | |
36 | turtle.select(j) | |
37 | turtle.drop() | |
38 | end | |
39 | turtle.turnLeft() | |
40 | turtle.turnLeft() | |
41 | if turtle.getItemCount(1) < 5 then --replenish sapling stocks | |
42 | turtle.turnLeft() | |
43 | turtle.select(1) | |
44 | turtle.suck() | |
45 | turtle.turnRight() | |
46 | - | for j = 3, 15 do -- empty slots 3 to 15 into chest |
46 | + | |
47 | end | |
48 | ||
49 | -- This function checks to see if the sapling has been fertilized into a full tree | |
50 | function compare() | |
51 | - | if turtle.getItemCount(16) < 5 then -- replenish fuel stocks |
51 | + | turtle.select(2) |
52 | - | turtle.select(16) |
52 | + | |
53 | - | turtle.suck(10) |
53 | + | return true -- false could indicate that there is no grown Baum |
54 | else | |
55 | return false | |
56 | end | |
57 | end | |
58 | ||
59 | -- This block triggers the appropriate functions in the correct order. | |
60 | repeat --start loop | |
61 | plant() --plant and fertilize tree | |
62 | turtle.digUp() | |
63 | turtle.up() | |
64 | repeat | |
65 | if compare() == true then --if tree has grown cut down tree | |
66 | - | turtle.select(1) |
66 | + | turtle.down() |
67 | fell() | |
68 | - | return true -- false could indicate that there is no bonemeal or saplings |
68 | + | else --if tree hasn't grown display error |
69 | sleep(10) | |
70 | turtle.suck() | |
71 | until 1 > 2 | |
72 | end | |
73 | empty() --empty harvest and restock fuel and materials | |
74 | until 1 > 2 -- always false creating infinite loop |