SHOW:
|
|
- or go back to the newest paste.
1 | local function checkFuel() | |
2 | if turtle.getFuelLevel() < 1 then | |
3 | turtle.select(1) | |
4 | turtle.refuel(1) | |
5 | end | |
6 | end | |
7 | -- | |
8 | local function Wood() | |
9 | if turtle.getItemCount(1) > 0 then | |
10 | print "Need wood in Slot 1!" | |
11 | while turtle.getItemCount(1) > 0 do | |
12 | sleep(0) | |
13 | end | |
14 | end | |
15 | end | |
16 | ||
17 | local function Saplings() | |
18 | print "Make sure Saplings are in Slot 16" | |
19 | sleep(1) | |
20 | Saplings = tonumber(turtle.getItemCount(16)) | |
21 | if Saplings > 3 then | |
22 | print "Something is in Slot 16.\nLet's hope that are saplings ;)" | |
23 | else | |
24 | print "Need at least 4 saplings in Slot 16" | |
25 | while Saplings < 4 do | |
26 | Saplings = tonumber(turtle.getItemCount(16)) | |
27 | sleep(0) | |
28 | end | |
29 | end | |
30 | end | |
31 | -- | |
32 | local function Ask() | |
33 | term.clear() | |
34 | term.setCursorPos(1,1) | |
35 | sleep(1) | |
36 | print "Enable Bonemeal? [y/n]" | |
37 | bm = read() | |
38 | end | |
39 | -- | |
40 | local function CheckInput() | |
41 | if bm == "y" or bm == "yes" or bm == "n" or bm == "no" then | |
42 | print("Input '" .. bm .. "'accepted") | |
43 | else | |
44 | error("Invalid Input! Ending program...",0) | |
45 | end | |
46 | end | |
47 | -- | |
48 | local function ConvertInput() | |
49 | if bm == "y" or bm == "yes" then | |
50 | bm = true | |
51 | toDrop = 14 | |
52 | elseif bm == "n" or bm == "no" then | |
53 | bm = false | |
54 | toDrop = 15 | |
55 | end | |
56 | bm1 = tostring(bm) | |
57 | print("bm = " .. bm1) | |
58 | print("Drop =" .. toDrop) | |
59 | end | |
60 | -- | |
61 | local function Start() | |
62 | turtle.dig() | |
63 | checkFuel() | |
64 | turtle.forward() | |
65 | end | |
66 | -- | |
67 | local function FellUp() | |
68 | up = 0 | |
69 | while turtle.detectUp() do | |
70 | turtle.digUp() | |
71 | turtle.dig() | |
72 | checkFuel() | |
73 | turtle.up() | |
74 | up = up + 1 | |
75 | end | |
76 | end | |
77 | -- | |
78 | local function Move() | |
79 | turtle.dig() | |
80 | checkFuel() | |
81 | turtle.turnRight() | |
82 | turtle.dig() | |
83 | turtle.forward() | |
84 | turtle.turnLeft() | |
85 | end | |
86 | -- | |
87 | local function FellDown() | |
88 | while up > 0 do | |
89 | turtle.dig() | |
90 | turtle.digDown() | |
91 | checkFuel() | |
92 | turtle.down() | |
93 | up = up - 1 | |
94 | end | |
95 | end | |
96 | -- | |
97 | local function Plant() --That's a mess. Sorry :) | |
98 | turtle.dig() | |
99 | checkFuel() | |
100 | turtle.up() | |
101 | turtle.select(16) | |
102 | turtle.placeDown() | |
103 | checkFuel() | |
104 | turtle.forward() | |
105 | turtle.select(16) | |
106 | turtle.placeDown() | |
107 | turtle.turnLeft() | |
108 | checkFuel() | |
109 | turtle.forward() | |
110 | turtle.select(16) | |
111 | turtle.placeDown() | |
112 | turtle.turnLeft() | |
113 | checkFuel() | |
114 | turtle.forward() | |
115 | turtle.select(16) | |
116 | turtle.placeDown() | |
117 | checkFuel() | |
118 | turtle.forward() | |
119 | checkFuel() | |
120 | turtle.turnRight() | |
121 | turtle.down() | |
122 | turtle.turnRight() | |
123 | end | |
124 | -- | |
125 | local function GetDrop() | |
126 | print(toDrop) | |
127 | if not toDrop == 14 and not toDrop == 15 then | |
128 | DropInvalid = 1 | |
129 | while DropInvalid == 1 do | |
130 | print "Something went wrong. Unable to drop." | |
131 | print "Drop everything? [y/n]" | |
132 | DropAll = read() | |
133 | if DropAll == y or DropAll == yes then | |
134 | for i = 1,16 do | |
135 | turtle.select(i) | |
136 | turtle.drop() | |
137 | end | |
138 | DropInvalid = 0 | |
139 | elseif DropAll == n or DropAll == no then | |
140 | print "Returning to start.\nPlease empty the inventory." | |
141 | turtle.turnRight() | |
142 | DropInvaild = 0 | |
143 | else | |
144 | print "Invalid Input! Reloading" | |
145 | term.clear() | |
146 | term.setCursorPos(1,1) | |
147 | sleep(1) | |
148 | DropInvalid = 1 --Still 1 | |
149 | end | |
150 | end | |
151 | end | |
152 | end | |
153 | -- | |
154 | local function Drop() | |
155 | for i = 2,toDrop do | |
156 | turtle.select(i) | |
157 | turtle.dropDown() | |
158 | end | |
159 | end | |
160 | -- | |
161 | local function MovetoChest() | |
162 | move = 10 | |
163 | checkFuel() | |
164 | while move > 0 do | |
165 | checkFuel() | |
166 | turtle.forward() | |
167 | move = move - 1 | |
168 | end | |
169 | end | |
170 | -- | |
171 | local function CheckRes() | |
172 | if bm == true then | |
173 | bmCount = turtle.getItemCount(15) | |
174 | end | |
175 | SaplingCount = turtle.getItemCount(16) | |
176 | print(bmCount) | |
177 | print(SaplingCount) | |
178 | end | |
179 | -- | |
180 | local function Decide() | |
181 | if bmCount < 2 and bm == true then | |
182 | NeedBonemeal = 1 | |
183 | else | |
184 | NeedBonemeal = 0 | |
185 | - | Ask() |
185 | + | |
186 | - | CheckInput() |
186 | + | |
187 | - | ConvertInput() |
187 | + | |
188 | else | |
189 | NeedSaplings = 0 | |
190 | end | |
191 | end | |
192 | -- | |
193 | - | print(Drop) |
193 | + | local function CheckTree() |
194 | - | GetDrop() |
194 | + | turtle.select(1) |
195 | - | Drop() |
195 | + | if turtle.compare() then |
196 | - | CheckRes() |
196 | + | return true |
197 | - | Decide() |
197 | + | |
198 | - | if Needbm == 1 or NeedSaplings == 1 then |
198 | + | return false |
199 | - | MovetoChest() |
199 | + | |
200 | - | GetRes = 1 |
200 | + | |
201 | --Begin | |
202 | - | turtle.turnRight() |
202 | + | While true do |
203 | - | GetRes = 0 |
203 | + | Wood() |
204 | end | |
205 | - | print(Needbm) |
205 | + | While CheckTree() do |
206 | - | print(NeedSaplings) |
206 | + | |
207 | - | print(GetRes) |
207 | + | |
208 | FellUp() | |
209 | Move() | |
210 | FellDown() | |
211 | Plant() | |
212 | turtle.turnRight() | |
213 | end |