View difference between Paste ID: mP7uSZm1 and Etc2zSyR
SHOW: | | - or go back to the newest paste.
1
version = "5"
2
  term.clear()
3
  term.setCursorPos(1, 1)
4
--print(version)
5
sleep(3)
6
done = 0
7
for l=1,10 do
8
if fs.exists("goto") == false 
9
then do
10
print("downloading goto")
11
shell.run("pastebin","get","Rj9UiYUJ","goto")
12
     if fs.exists("goto") == true then
13
            print("download complete") 
14
                elseif fs.exists("goto") == false then
15
                print("download failed")
16
                end
17
end
18
else do
19
            
20
  term.clear()
21
  term.setCursorPos(1, 1)                           
22
 print("recentering")           
23
while true do
24
if done ~= 4 then do
25-
--CHANGE HERE START
25+
26-
lenth = 5
26+
27-
st_width = 5
27+
28-
--CHANGE HERE END
28+
29
---------------------                        
30
---------------------                        
31
--------------------- 
32
--CHANGE HERE START--
33
---------------------
34
---------------------                        
35
---------------------                        
36-
totalsteps = 2 
36+
37
                        
38
--"1" is Normal, "2" is Pumpkin/Melon/Probably Sugar Cane                    
39
Mode = 2
40
                        
41
Farm_Lenth = 5
42
Farm_Width = 7
43
44
 
45
46-
shell.run("goto", "359", "88", "629")
46+
                      
47
-- sort for specific crop                        
48
49
--whether or not to sort, 1 is yes, 0 is no                        
50
sortblock = 1  
51
--name of the crop                        
52
crop_name = "minecraft:pumpkin"                        
53-
    while chest ~= 17 do
53+
--Recenter Values
54
    turn_right_recenter_times = 0
55
    forward_recenter_times = 1                  
56
                        
57-
  end   
57+
--max age of crop should probably be left at 7
58
crop_max_age = 7                       
59
                        
60
                        
61
                        
62
                        
63
--setup1 location
64
  setup1X = 304
65
  setup1Y = 66
66
  setup1Z = 327
67
--setup2 location                        
68
  setup2X = 304
69
  setup2Y = 66
70
  setup2Z = 326               
71
                        
72
                        
73
                        
74
                    
75
--chest location                      
76
      chestX =  304
77
      chestY =  65                
78
      chestZ =  326  
79
--chest 2 = "up", 1 = "down", or 0 = "forward"                        
80
chestdirection = 0                       
81
                        
82
    --misc
83
                        
84
                      --ignore if a crop has no age value should be set at 1 for Pumpkin/Melon and 0 for Normal 
85
                        Override_ignore_nil_age = 0
86
                        ignore_nil_age = 1  
87-
function recenter() 
87+
88
                        override_stages = 0
89
                        turnleftchest = 0
90-
shell.run("goto", "363", "89", "631")
90+
                        totalstages = 1
91
                        
92-
shell.run("goto", "359", "89", "629")
92+
93
-------------------                        
94
-------------------
95
--CHANGE HERE END--
96
-------------------        
97-
turtle.forward()                 
97+
-------------------
98-
turtle.forward()                             
98+
99
                        
100
                        
101
                        
102
                        
103
                        
104
if Override_ignore_nil_age == 0 then
105
   if Mode == 2 then                          
106
         ignore_nil_age = 1
107-
  if done == 3 then
107+
   elseif Mode == 1 then                            
108
         ignore_nil_age = 0                         
109
   end                          
110
end                     
111
                        
112
st_width = Farm_Width
113
lenth = Farm_Lenth                       
114
if override_stages == 1 then
115
totalsteps = totalstages
116
     if Mode == 2 then
117
       grabstage = 5 
118
       elseif Mode == 1 then
119
       grabstage = 2                        
120
     end                              
121
elseif Mode == 2 then
122
   if override_stages == 0 then                         
123
         grabstage = 5                   
124
       totalstages = 1                    
125
 totalsteps = 1   
126
     end                                                       
127
 elseif  Mode == 1 then
128-
                 ---REPLACE LATER!!!!!!                           
128+
   if override_stages == 0 then                         
129
       grabstage = 2                     
130
       totalstages = 2                    
131-
                 print ("Stage: " .. done .. "/" .. totalsteps.. " Harvest and Plant")                             
131+
 totalsteps = 2   
132
     end                           
133-
         if success then                                    
133+
  end                      
134
totalsteps = totalstages                                              
135
endsteps = totalsteps + 1                    
136-
                                                percentagefloat = (data.state.age - 0) / (7 - 0) * 100 
136+
137
function chest()                        
138
 term.clear()
139
        term.setCursorPos(1, 1)                                
140
       print("going to chest")                         
141-
     if data.state.age == 7 then
141+
shell.run("goto", chestX, chestY, chestZ)
142
                          
143
    if Mode == 2 then
144
     chest = 1
145
      elseif  Mode == 1 then                         
146
    chest = 2
147-
                 --print("dig")                               
147+
148
        term.clear()
149
        term.setCursorPos(1, 1)                          
150-
                  turtle.placeDown()                         
150+
151-
                 ---REPLACE LATER END!!!!!!                           
151+
    while chest <= 16 do
152
    turtle.select(chest)
153
  if chestdirection == 0 then  
154-
                   turtle.forward()                         
154+
      turtle.drop()                              
155-
                   term.setCursorPos(1, 1) 
155+
                                   
156
        elseif chestdirection == 1 then
157-
                 print ("Stage: " .. done .. "/" .. totalsteps.. " Harvest and Plant")                             
157+
                    
158
    turtle.dropDown()
159-
         if success then                                    
159+
    elseif chestdirection == 2 then                           
160
      turtle.dropUp()
161
            end                        
162-
                                                percentagefloat = (data.state.age - 0) / (7 - 0) * 100 
162+
163
                                    
164
    chest = chest + 1 
165
  end
166
      if turnleftchest == 1 then
167-
     if data.state.age == 7 then
167+
          turtle.turnLeft()
168
                                end
169
     term.clear()
170
        term.setCursorPos(1, 1)                                
171
       print("Resetting")                        
172
   sleep(20) 
173-
                 --print("dig")                               
173+
174
 end                               
175
                                
176-
                  turtle.placeDown()                    
176+
177-
                  
177+
178-
                                           
178+
179-
         
179+
180
if right == 1 then 
181
                                   --print("right")
182
turtle.turnRight()
183
turtle.forward()
184
turtle.turnRight()
185
186
dist = sub_lenth
187
width = width - 1
188
right = 0
189
else
190-
elseif done == 2 then
190+
191
turtle.turnLeft()
192
turtle.forward()
193
turtle.turnLeft()
194-
                     ---REPLACE LATER!!!!!!  
194+
195-
                                         term.setCursorPos(1, 1)   
195+
196-
                                        term.clearLine()
196+
197
end
198
end
199-
                   ---REPLACE LATER END!!!!!!                          
199+
200
                        
201-
        term.setCursorPos(1, 1)
201+
function recenter()                             
202-
                                 term.clearLine()
202+
working_turn_right_recenter_times = turn_right_recenter_times
203
                            
204
working_forward_recenter_times = forward_recenter_times
205
                            
206-
                                    --print("grab")
206+
shell.run("goto", setup1X, setup1Y, setup1Z)
207
shell.run("goto", setup2X, setup2Y, setup2Z) 
208
if turn_right_recenter_times ~= 0 then
209
    while working_turn_right_recenter_times ~= 0 do
210
        turtle.turnRight()
211
        working_turn_right_recenter_times = working_turn_right_recenter_times - 1      
212
    end                                
213-
--unused planting phase not needed because in can be done after digging
213+
end                           
214-
elseif done == 4 then
214+
215
right = 1
216
turtle.select(1)
217
dist = lenth - 1
218
  if forward_recenter_times ~= 0 then  
219
     while working_forward_recenter_times ~= 0 do                          
220
      turtle.forward()   
221
      working_forward_recenter_times = working_forward_recenter_times - 1                              
222
     end                         
223
  end                              
224
                                
225
end
226
                        
227
 
228
                        
229
                        
230
function stage1()    
231
                            
232
                          
233
                                       term.setCursorPos(1, 1) 
234
                   term.clearLine()                         
235
                 print ("Stage: " .. done .. "/" .. totalsteps.. " Harvest and Plant")    
236
                            
237
       success, data = turtle.inspectDown()  
238
         if success then         
239
                             
240
                                
241
                                if data.state.age ~= nil then
242
                                    
243
                                    
244
                                            term.setCursorPos(1, 2)
245
                                                term.clearLine()
246
                                               percentagefloat = (data.state.age - 0) / (7 - 0) * 100 
247
                                                percentage = math.floor(percentagefloat+0.5)
248
                                                
249
                                                print("Crop Age: " .. percentage .. "%")
250
                                    end
251
--         if ignore_nil_age == 1 then
252
 --    if data.state.age == nil then
253
   --         data.state.age = crop_max_age                        
254
   --  end
255
 --end                               
256
                             
257
 if data.name == crop_name or sortblock == 0 then   
258
       if data.state.age == crop_max_age or ignore_nil_age == 1 then
259
           --print("Age Check 2: " .. data.state.age)                                          
260
        turtle.digDown()
261
                 turtle.suckDown()                                   
262
                 --term.setCursorPos(1, 3)
263
                  --term.clearLine()                                   
264
                 --print("dig")   
265
                                        
266
                                     
267
              end 
268
                end 
269
                                            
270
                  if Mode == 1 then                          
271
                  turtle.placeDown()                            
272
                    end                 
273
       end        
274
end        
275
276
                        
277
                        
278
function stage2()   
279
                            
280
                            
281
                            
282
                            term.setCursorPos(1, 1)
283
                                  term.clearLine()
284
                            
285
                                            print ("Stage: " .. done .. "/" .. totalsteps .. " Cleanup")                                    
286
        turtle.suckDown()
287
       
288
                                    --print("grab")                       
289
                        
290
                        
291
                        
292
end                        
293
                        
294
                        
295
296
if width == 0 or width == nil  then
297
 done = done + 1 
298
      --print ("add")                      
299
    --print ("Steps: " .. done) 
300
  if done == endsteps then
301
                               recenter() 
302
                                chest()
303
                                  done = 0
304
                                    end
305
306
width = st_width 
307
                            --print("width: " .. width)
308
                            recenter()
309
 elseif width ~= 0 then
310
                                
311
                            
312
                            
313
if dist ~= 0 then                           
314
           
315
                          
316
if done == 1 then
317
term.clear() 
318
   while width ~= 0 do                                 
319
    while dist ~= 0 do                          
320
stage1()                                
321
turtle.forward()                         
322
stage1() 
323
--print("dig")
324
       dist = dist - 1
325
                                                    
326
              
327
         end                               
328
   turn()
329
   
330
       end                             
331
332
elseif done == grabstage then
333
     term.clear()                                
334
   while width ~= 0 do                                  
335
    while dist ~= 0 do 
336
stage2()                        
337
turtle.forward()
338
stage2()
339
                                               
340
       dist = dist - 1
341
       end
342
       turn()                                 
343
    end
344
                                        
345
--unused planting phase not needed because it can be done after digging
346
elseif done == 9 then
347
    
348
   while width ~= 0 do                                 
349
    while dist ~= 0 do
350
        turtle.placeDown()
351
        turtle.forward()
352
       print("plant")
353
            print ("Steps: " .. done)                                  
354
   dist = dist - 1
355
       end
356
       turn()                                       
357
    end
358
      --end- unused planting phase end                         
359
360
 end
361
362
                                    end
363
364
365
                               
366
367
368
369
370
end
371
end
372
end
373
end                    
374
end                    
375
    end                
376
    end