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