SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Author: ArbitraryHubris | |
| 2 | - | -- place saplings in slot 1, bone meal in slot 2 |
| 2 | + | -- place saplings in slot 1 |
| 3 | ||
| 4 | unknown, saplings = 0, 1 | |
| 5 | ||
| 6 | local function plantSaplings() | |
| 7 | -- clear and plant logs in 2x2 layout and return to starting position | |
| 8 | print("Planting saplings")
| |
| 9 | turtle.select(1) | |
| 10 | turtle.dig() | |
| 11 | turtle.forward() | |
| 12 | turtle.dig() | |
| 13 | turtle.forward() | |
| 14 | turtle.turnRight() | |
| 15 | turtle.dig() | |
| 16 | turtle.place() | |
| 17 | turtle.turnLeft() | |
| 18 | turtle.back() | |
| 19 | turtle.place() | |
| 20 | turtle.turnRight() | |
| 21 | turtle.dig() | |
| 22 | turtle.place() | |
| 23 | turtle.turnLeft() | |
| 24 | turtle.back() | |
| 25 | turtle.place() | |
| 26 | - | turtle.select(2) |
| 26 | + | |
| 27 | end | |
| 28 | ||
| 29 | ||
| 30 | local function detectItem() | |
| 31 | turtle.select(saplings) | |
| 32 | if turtle.compare() then | |
| 33 | -- print("Detected sapling")
| |
| 34 | return saplings | |
| 35 | end | |
| 36 | return unknown | |
| 37 | end | |
| 38 | ||
| 39 | ||
| 40 | local function fell() | |
| 41 | height = 0 | |
| 42 | turtle.dig() | |
| 43 | turtle.forward() | |
| 44 | while turtle.detectUp() do | |
| 45 | height = height + 1 | |
| 46 | turtle.digUp() | |
| 47 | turtle.dig() | |
| 48 | turtle.up() | |
| 49 | end | |
| 50 | turtle.turnRight() | |
| 51 | turtle.dig() | |
| 52 | turtle.forward() | |
| 53 | turtle.turnLeft() | |
| 54 | while height > 0 do | |
| 55 | turtle.dig() | |
| 56 | turtle.digDown() | |
| 57 | turtle.down() | |
| 58 | height = height - 1 | |
| 59 | end | |
| 60 | turtle.down() | |
| 61 | turtle.dig() | |
| 62 | turtle.turnLeft() | |
| 63 | turtle.forward() | |
| 64 | turtle.turnLeft() | |
| 65 | turtle.forward() | |
| 66 | for i = 2,16 do | |
| 67 | turtle.select(i) | |
| 68 | - | for i = 3,16 do |
| 68 | + | |
| 69 | end | |
| 70 | turtle.turnLeft() | |
| 71 | turtle.turnLeft() | |
| 72 | end | |
| 73 | ||
| 74 | ||
| 75 | local function waitForTree() | |
| 76 | seconds = 0 | |
| 77 | while true do | |
| 78 | print("Waiting for sapling to grow for " .. seconds .. " seconds")
| |
| 79 | os.sleep(10) | |
| 80 | seconds = seconds + 10 | |
| 81 | if detectItem() ~= saplings then | |
| 82 | return | |
| 83 | end | |
| 84 | end | |
| 85 | end | |
| 86 | ||
| 87 | ||
| 88 | while true do | |
| 89 | plantSaplings() | |
| 90 | waitForTree() | |
| 91 | fell() | |
| 92 | end |