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