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