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