SHOW:
|
|
- or go back to the newest paste.
| 1 | function f(loc) | |
| 2 | while not turtle[loc]() do | |
| 3 | sleep(0.5) | |
| 4 | end | |
| 5 | end | |
| 6 | function up() f("up") end
| |
| 7 | function down() f("down") end
| |
| 8 | function fw() f("forward") end
| |
| 9 | function back() f("back") end
| |
| 10 | function l() f("turnLeft") end
| |
| 11 | function r() f("turnRight") end
| |
| 12 | function d() turtle.dig() end | |
| 13 | function du() turtle.digUp() end | |
| 14 | function dd() turtle.digDown() end | |
| 15 | function c(x) | |
| 16 | for i=1,x do d() fw() du() dd() end | |
| 17 | end | |
| 18 | ||
| 19 | function makeTree() | |
| 20 | if turtle.getItemCount(1)==0 then | |
| 21 | print("Not enough Saplings.")
| |
| 22 | return | |
| 23 | end | |
| 24 | ||
| 25 | if turtle.getItemCount(2)==0 then | |
| 26 | print("Not enough BoneMeal.")
| |
| 27 | return | |
| 28 | end | |
| 29 | turtle.select(1) | |
| 30 | turtle.place() | |
| 31 | sleep(1) | |
| 32 | turtle.select(2) | |
| 33 | turtle.place() | |
| 34 | sleep(1) | |
| 35 | end | |
| 36 | ||
| 37 | ||
| 38 | ||
| 39 | function resetPos() | |
| 40 | print("Resetting position.")
| |
| 41 | ||
| 42 | r=0 | |
| 43 | while r==0 do | |
| 44 | - | turtle.down() |
| 44 | + | down() |
| 45 | if turtle.detectDown()==true then | |
| 46 | r=1 | |
| 47 | end | |
| 48 | end | |
| 49 | - | turtle.back() |
| 49 | + | back() |
| 50 | end | |
| 51 | ||
| 52 | - | --function cutTree() |
| 52 | + | |
| 53 | - | -- sleep(2) |
| 53 | + | |
| 54 | print("tree cut")
| |
| 55 | hi = 0 | |
| 56 | - | --print("Cutting Tree.")
|
| 56 | + | while not turtle.detectUp() and hi<7 do |
| 57 | - | -- sleep(2) |
| 57 | + | |
| 58 | - | -- turtle.dig() |
| 58 | + | |
| 59 | - | -- turtle.forward() |
| 59 | + | |
| 60 | - | -- y=1 |
| 60 | + | |
| 61 | - | -- while y==1 do |
| 61 | + | |
| 62 | - | -- turtle.digUp() |
| 62 | + | |
| 63 | - | -- turtle.up() |
| 63 | + | |
| 64 | - | -- if turtle.detectUp()==false then |
| 64 | + | |
| 65 | - | -- y=0 |
| 65 | + | |
| 66 | - | -- end |
| 66 | + | |
| 67 | - | -- end |
| 67 | + | |
| 68 | - | -- |
| 68 | + | |
| 69 | - | --resetPos() |
| 69 | + | |
| 70 | - | --end |
| 70 | + | |
| 71 | - | |
| 71 | + | |
| 72 | -- Checking saplings slot | |
| 73 | print("Checking for mats.")
| |
| 74 | sleep(2) | |
| 75 | - | while not turtle.detectUp() do |
| 75 | + | |
| 76 | print("Not enough Saplings.")
| |
| 77 | s=1 | |
| 78 | turtle.turnLeft() | |
| 79 | turtle.select(1) | |
| 80 | turtle.suck() | |
| 81 | turtle.turnRight() | |
| 82 | if turtle.getItemCount(1)>0 then | |
| 83 | s=0 | |
| 84 | end | |
| 85 | end | |
| 86 | ||
| 87 | -- Checking bonemeal slot | |
| 88 | if turtle.getItemCount(2)==0 then | |
| 89 | print("Not enough bonemeal.")
| |
| 90 | turtle.turnLeft() | |
| 91 | turtle.turnLeft() | |
| 92 | turtle.select(1) | |
| 93 | turtle.suck() | |
| 94 | turtle.turnRight() | |
| 95 | turtle.turnRight() | |
| 96 | end | |
| 97 | ||
| 98 | end | |
| 99 | ||
| 100 | function checkStop() | |
| 101 | if s==0 then | |
| 102 | shell.exit() | |
| 103 | end | |
| 104 | end | |
| 105 | ||
| 106 | function ConsolidateMats() | |
| 107 | turtle.turnLeft() | |
| 108 | print("Consolidating saplings.")
| |
| 109 | for i=3,15 do | |
| 110 | turtle.select(i) | |
| 111 | ||
| 112 | if turtle.compareTo(1) then -- It's a sapling not in slot one | |
| 113 | turtle.drop() -- put it in the chest to our left | |
| 114 | end | |
| 115 | end | |
| 116 | turtle.turnRight() | |
| 117 | print("Sending all other mats to processing.")
| |
| 118 | for i=3,15 do | |
| 119 | turtle.select(i) | |
| 120 | turtle.dropDown() | |
| 121 | end | |
| 122 | end | |
| 123 | ||
| 124 | while true do | |
| 125 | makeTree() | |
| 126 | checkMats() | |
| 127 | cutTree() | |
| 128 | ConsolidateMats() | |
| 129 | checkStop() | |
| 130 | end |