SHOW:
|
|
- or go back to the newest paste.
| 1 | function move() | |
| 2 | turtle.dig() | |
| 3 | turtle.forward() | |
| 4 | end | |
| 5 | ||
| 6 | function turn() | |
| 7 | turtle.turnRight() | |
| 8 | move() | |
| 9 | end | |
| 10 | ||
| 11 | function chopUp() | |
| 12 | while turtle.detectUp() do | |
| 13 | turtle.digUp() | |
| 14 | turtle.up() | |
| 15 | end | |
| 16 | end | |
| 17 | ||
| 18 | function checkBelow() | |
| 19 | if turtle.detectDown() then | |
| 20 | success, data = turtle.inspectDown() | |
| 21 | if success then | |
| 22 | if data.name ~= "minecraft:log" or data.name ~= "minecraft:leaves" then | |
| 23 | return false | |
| 24 | - | end |
| 24 | + | else |
| 25 | return true | |
| 26 | end | |
| 27 | - | return false |
| 27 | + | |
| 28 | else | |
| 29 | return false | |
| 30 | end | |
| 31 | end | |
| 32 | ||
| 33 | ||
| 34 | function chopDown() | |
| 35 | repeat | |
| 36 | turtle.digDown() | |
| 37 | turtle.down() | |
| 38 | until not checkBelow() | |
| 39 | end | |
| 40 | ||
| 41 | function placeSapling() | |
| 42 | turtle.select(2) | |
| 43 | turtle.place() | |
| 44 | turtle.select(1) | |
| 45 | end | |
| 46 | ||
| 47 | function reUp() | |
| 48 | if turtle.getItemCount(1) == 0 then | |
| 49 | turtle.select(1) | |
| 50 | turtle.suckDown() | |
| 51 | end | |
| 52 | end | |
| 53 | ||
| 54 | function treeGrew() | |
| 55 | local success, data = turtle.inspect() | |
| 56 | if success then | |
| 57 | if data.name == "minecraft:log" or data.name == "minecraft:log"then | |
| 58 | return true; | |
| 59 | else | |
| 60 | return false; | |
| 61 | end | |
| 62 | end | |
| 63 | end | |
| 64 | ||
| 65 | function growTree() | |
| 66 | repeat | |
| 67 | reUp() | |
| 68 | turtle.place() | |
| 69 | until treeGrew() | |
| 70 | end | |
| 71 | ||
| 72 | ||
| 73 | while true do | |
| 74 | growTree() | |
| 75 | move() | |
| 76 | chopUp() | |
| 77 | move() | |
| 78 | chopUp() | |
| 79 | chopDown() | |
| 80 | turn() | |
| 81 | chopUp() | |
| 82 | move() | |
| 83 | chopUp() | |
| 84 | chopDown() | |
| 85 | turn() | |
| 86 | placeSapling() | |
| 87 | end |