SHOW:
|
|
- or go back to the newest paste.
| 1 | --Min is 3 for H-- | |
| 2 | lengthMax = 50 | |
| 3 | widthMax = 3 | |
| 4 | heightMax = 3 | |
| 5 | orientation = 4 | |
| 6 | --N=4, E=3, S=2, W=1-- | |
| 7 | orientations = {"north", "east", "south", "west"}
| |
| 8 | startDirection = orientation | |
| 9 | ||
| 10 | xCurrent = 0 | |
| 11 | zCurrent = 0 | |
| 12 | yCurrent = 0 | |
| 13 | ||
| 14 | xHome = 0 | |
| 15 | zHome = 0 | |
| 16 | yHome = 0 | |
| 17 | ||
| 18 | xBlackcurrant = 0 | |
| 19 | zBlackcurrant = 0 | |
| 20 | yBlackcurrant = 0 | |
| 21 | orientationLast = orientation | |
| 22 | ||
| 23 | zDiff = {-1, 0, 1, 0}
| |
| 24 | xDiff = {0, 1, 0 ,-1}
| |
| 25 | ||
| 26 | turn = 1 | |
| 27 | turnLast = turn | |
| 28 | lengthCurrent = lengthMax | |
| 29 | placeTorch = 10 | |
| 30 | width = widthMax | |
| 31 | finishWalk = widthMax | |
| 32 | heightCheck = heightMax | |
| 33 | heightMax = heightMax - 3 | |
| 34 | height = heightMax | |
| 35 | ending = false | |
| 36 | kill = false | |
| 37 | said = false | |
| 38 | fuelSaid = false | |
| 39 | selectedSlot = 16 | |
| 40 | answer = "F" | |
| 41 | facingAnswer = 0 | |
| 42 | torchesGoCheck = "Pickles" | |
| 43 | startUpComplete = false | |
| 44 | saidYes = "Rainbows" | |
| 45 | fuelYes = "Cabbages" | |
| 46 | hasTorch = false | |
| 47 | lengthSet = 0 | |
| 48 | widthSet = 0 | |
| 49 | heightSet = 0 | |
| 50 | fuelLevel = turtle.getFuelLevel() | |
| 51 | ||
| 52 | function fillFacing() | |
| 53 | print("Fill in which way I'm facing: ")
| |
| 54 | print("North=4, East=3, South=2, West=1")
| |
| 55 | facingAnswer = tonumber(read()) | |
| 56 | while not(facingAnswer == 1 or facingAnswer == 2 or facingAnswer == 3 or facingAnswer == 4) do | |
| 57 | print("ERROR! Please try again!")
| |
| 58 | print("Fill in which way I'm facing: ")
| |
| 59 | print("North=4, East=3, South=2, West=1")
| |
| 60 | facingAnswer = tonumber(read()) | |
| 61 | end | |
| 62 | orientation = facingAnswer | |
| 63 | startDirection = orientation | |
| 64 | orientationLast = orientation | |
| 65 | shell.run("clear")
| |
| 66 | end | |
| 67 | ||
| 68 | function answerWrong() | |
| 69 | print("ERROR! Please try again!")
| |
| 70 | print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
| |
| 71 | print("If 'N' then I will use the Default")
| |
| 72 | print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
| |
| 73 | answer = read() | |
| 74 | shell.run("clear")
| |
| 75 | end | |
| 76 | ||
| 77 | function runStartup() | |
| 78 | if startUpComplete == false then | |
| 79 | shell.run("clear")
| |
| 80 | print("I'm going to build you a room, Master.")
| |
| 81 | print(" ")
| |
| 82 | print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
| |
| 83 | print("If 'N' then I will use the Default")
| |
| 84 | print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
| |
| 85 | answer = read() | |
| 86 | while not(answer == "Y" or answer == "N") do | |
| 87 | print("ERROR! Please try again!")
| |
| 88 | print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
| |
| 89 | print("If 'N' then I will use the Default")
| |
| 90 | print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
| |
| 91 | answer = read() | |
| 92 | shell.run("clear")
| |
| 93 | end | |
| 94 | if answer == "N" then | |
| 95 | fillFacing() | |
| 96 | heightMax = heightMax + 3 | |
| 97 | heightCheck = heightMax | |
| 98 | heightMax = heightMax - 3 | |
| 99 | height = heightMax | |
| 100 | startUpComplete = true | |
| 101 | elseif answer == "Y" then | |
| 102 | shell.run("clear")
| |
| 103 | print("Please Fill the Dimensions!")
| |
| 104 | print(" ")
| |
| 105 | print("Fill in the Length:")
| |
| 106 | lengthSet = tonumber(read()) | |
| 107 | lengthMax = lengthSet | |
| 108 | lengthCurrent = lengthMax | |
| 109 | while lengthSet == nil do | |
| 110 | print("ERROR! Please try again!")
| |
| 111 | print("Fill in the Length:")
| |
| 112 | lengthSet = tonumber(read()) | |
| 113 | lengthMax = lengthSet | |
| 114 | lengthCurrent = lengthMax | |
| 115 | shell.run("clear")
| |
| 116 | end | |
| 117 | shell.run("clear")
| |
| 118 | print("Please Fill the Dimensions!")
| |
| 119 | print(" ")
| |
| 120 | print("Fill in the Width:")
| |
| 121 | widthSet = tonumber(read()) | |
| 122 | widthMax = widthSet | |
| 123 | width = widthMax | |
| 124 | while widthSet == nil do | |
| 125 | print("ERROR! Please try again!")
| |
| 126 | print("Fill in the Width:")
| |
| 127 | widthSet = tonumber(read()) | |
| 128 | widthMax = widthSet | |
| 129 | width = widthMax | |
| 130 | shell.run("clear")
| |
| 131 | end | |
| 132 | shell.run("clear")
| |
| 133 | print("Please Fill the Dimensions!")
| |
| 134 | print(" ")
| |
| 135 | print("Fill in the Height:")
| |
| 136 | heightSet = tonumber(read()) | |
| 137 | heightMax = heightSet | |
| 138 | heightCheck = heightMax | |
| 139 | heightMax = heightMax - 3 | |
| 140 | height = heightMax | |
| 141 | while heightSet == nil or heightSet < 3 do | |
| 142 | print("ERROR! Please try again!")
| |
| 143 | print("Fill in the Height:")
| |
| 144 | heightSet = tonumber(read()) | |
| 145 | heightMax = heightSet | |
| 146 | heightCheck = heightMax | |
| 147 | heightMax = heightMax - 3 | |
| 148 | height = heightMax | |
| 149 | shell.run("clear")
| |
| 150 | end | |
| 151 | shell.run("clear")
| |
| 152 | fillFacing() | |
| 153 | shell.run("clear")
| |
| 154 | print("I will now start, Master.")
| |
| 155 | print(" ")
| |
| 156 | startUpComplete = true | |
| 157 | end | |
| 158 | end | |
| 159 | end | |
| 160 | ||
| 161 | function torchGo() | |
| 162 | while not(torchesGoCheck == "Go") do | |
| 163 | print("ERROR! Please try Again")
| |
| 164 | print("Once I have Torches Type: 'Go'")
| |
| 165 | torchesGoCheck = read() | |
| 166 | shell.run("clear")
| |
| 167 | end | |
| 168 | end | |
| 169 | ||
| 170 | function torchAdded() | |
| 171 | while not(saidYes == "Y") do | |
| 172 | shell.run("clear")
| |
| 173 | print("ERROR! Please try Again")
| |
| 174 | print("Once I have Torches, Type: 'Y'")
| |
| 175 | saidYes = read() | |
| 176 | end | |
| 177 | end | |
| 178 | ||
| 179 | function saidCheck() | |
| 180 | shell.run("clear")
| |
| 181 | print("I need Torches in Slot.1, Master.")
| |
| 182 | print("Once I have Torches Type: 'Y'")
| |
| 183 | saidYes = read() | |
| 184 | torchAdded() | |
| 185 | end | |
| 186 | ||
| 187 | function torchCheck() | |
| 188 | while not(turtle.getItemDetail("minecraft:torch")) do
| |
| 189 | if said == false then | |
| 190 | saidCheck() | |
| 191 | hasTorch = true | |
| 192 | end | |
| 193 | end | |
| 194 | if hasTorch == true then | |
| 195 | shell.run("clear")
| |
| 196 | print("I'm Ready, Master. Type: 'Go' to Start")
| |
| 197 | torchesGoCheck = read() | |
| 198 | torchGo() | |
| 199 | end | |
| 200 | shell.run("clear")
| |
| 201 | hasTorch = false | |
| 202 | said = false | |
| 203 | end | |
| 204 | ||
| 205 | function fuelCheck() | |
| 206 | fuelLevel = turtle.getFuelLevel() | |
| 207 | while not(fuelLevel > 0) do | |
| 208 | if fuelSaid == false then | |
| 209 | fuelSaidCheck() | |
| 210 | hasFuel = true | |
| 211 | end | |
| 212 | shell.run("refuel all")
| |
| 213 | fuelLevel = turtle.getFuelLevel() | |
| 214 | end | |
| 215 | if hasFuel == true then | |
| 216 | shell.run("clear")
| |
| 217 | print("I'm Ready, Master. Type: 'Go' to Start")
| |
| 218 | fuelGoCheck = read() | |
| 219 | fuelGo() | |
| 220 | end | |
| 221 | shell.run("clear")
| |
| 222 | hasFuel = false | |
| 223 | fuelSaid = false | |
| 224 | end | |
| 225 | ||
| 226 | function fuelGo() | |
| 227 | while not(fuelGoCheck == "Go") do | |
| 228 | print("ERROR! Please try Again")
| |
| 229 | print("Once I have Fuel Type: 'Go'")
| |
| 230 | fuelGoCheck = read() | |
| 231 | shell.run("clear")
| |
| 232 | end | |
| 233 | end | |
| 234 | ||
| 235 | function fuelAdded() | |
| 236 | while not(fuelYes == "Y") do | |
| 237 | shell.run("clear")
| |
| 238 | print("ERROR! Please try Again")
| |
| 239 | print("Once I have Fuel, Type: 'Y'")
| |
| 240 | fuelYes = read() | |
| 241 | end | |
| 242 | end | |
| 243 | ||
| 244 | function fuelSaidCheck() | |
| 245 | shell.run("clear")
| |
| 246 | print("I need Fuel, Master.")
| |
| 247 | print("Once I have Fuel Type: 'Y'")
| |
| 248 | fuelYes = read() | |
| 249 | fuelAdded() | |
| 250 | end | |
| 251 | ||
| 252 | function left() | |
| 253 | orientation = orientation - 1 | |
| 254 | orientation = (orientation - 1) % 4 | |
| 255 | orientation = orientation + 1 | |
| 256 | ||
| 257 | turtle.turnLeft() | |
| 258 | end | |
| 259 | ||
| 260 | function right() | |
| 261 | orientation = orientation - 1 | |
| 262 | orientation = (orientation + 1) % 4 | |
| 263 | orientation = orientation + 1 | |
| 264 | ||
| 265 | turtle.turnRight() | |
| 266 | end | |
| 267 | ||
| 268 | function look(direction) | |
| 269 | while direction ~= orientations[orientation] do | |
| 270 | right() | |
| 271 | end | |
| 272 | end | |
| 273 | ||
| 274 | function moveForward() | |
| 275 | while turtle.detect() do | |
| 276 | turtle.dig() | |
| 277 | end | |
| 278 | moved = false | |
| 279 | while not(moved) do | |
| 280 | moved = turtle.forward() | |
| 281 | end | |
| 282 | xCurrent = xCurrent + xDiff[orientation] | |
| 283 | zCurrent = zCurrent + zDiff[orientation] | |
| 284 | end | |
| 285 | ||
| 286 | function digForward() | |
| 287 | while turtle.detect() do | |
| 288 | turtle.dig() | |
| 289 | end | |
| 290 | end | |
| 291 | ||
| 292 | function digBelow() | |
| 293 | while turtle.detectDown() do | |
| 294 | turtle.digDown() | |
| 295 | end | |
| 296 | end | |
| 297 | ||
| 298 | function digAbove() | |
| 299 | while turtle.detectUp() do | |
| 300 | turtle.digUp() | |
| 301 | end | |
| 302 | end | |
| 303 | ||
| 304 | function moveUp() | |
| 305 | turtle.digUp() | |
| 306 | moved = false | |
| 307 | while not(moved) do | |
| 308 | digAbove() | |
| 309 | moved = turtle.up() | |
| 310 | end | |
| 311 | yCurrent = yCurrent + 1 | |
| 312 | end | |
| 313 | ||
| 314 | function moveDown() | |
| 315 | turtle.digDown() | |
| 316 | moved = false | |
| 317 | while not(moved) do | |
| 318 | moved = turtle.down() | |
| 319 | end | |
| 320 | yCurrent = yCurrent - 1 | |
| 321 | end | |
| 322 | ||
| 323 | function goDown() | |
| 324 | moved = false | |
| 325 | while not(moved) do | |
| 326 | turtle.digDown() | |
| 327 | moved = turtle.down() | |
| 328 | end | |
| 329 | yCurrent = yCurrent - 1 | |
| 330 | end | |
| 331 | ||
| 332 | function goUp() | |
| 333 | moved = false | |
| 334 | while not(moved) do | |
| 335 | digAbove() | |
| 336 | moved = turtle.up() | |
| 337 | end | |
| 338 | yCurrent = yCurrent + 1 | |
| 339 | end | |
| 340 | ||
| 341 | function upBreak() | |
| 342 | digAbove() | |
| 343 | goUp() | |
| 344 | digAbove() | |
| 345 | end | |
| 346 | ||
| 347 | function leftDig() | |
| 348 | left() | |
| 349 | moveForward() | |
| 350 | digAbove() | |
| 351 | digBelow() | |
| 352 | while height > 0 do | |
| 353 | upBreak() | |
| 354 | height = height - 1 | |
| 355 | end | |
| 356 | height = heightMax | |
| 357 | while height > 0 do | |
| 358 | moveDown() | |
| 359 | height = height - 1 | |
| 360 | end | |
| 361 | height = heightMax | |
| 362 | left() | |
| 363 | end | |
| 364 | ||
| 365 | function rightDig() | |
| 366 | right() | |
| 367 | moveForward() | |
| 368 | digAbove() | |
| 369 | digBelow() | |
| 370 | while height > 0 do | |
| 371 | upBreak() | |
| 372 | height = height - 1 | |
| 373 | end | |
| 374 | height = heightMax | |
| 375 | while height > 0 do | |
| 376 | moveDown() | |
| 377 | height = height - 1 | |
| 378 | end | |
| 379 | height = heightMax | |
| 380 | right() | |
| 381 | end | |
| 382 | ||
| 383 | function leftWalk() | |
| 384 | left() | |
| 385 | moveForward() | |
| 386 | digAbove() | |
| 387 | digBelow() | |
| 388 | while height > 0 do | |
| 389 | upBreak() | |
| 390 | height = height - 1 | |
| 391 | end | |
| 392 | height = heightMax | |
| 393 | while height > 0 do | |
| 394 | moveDown() | |
| 395 | height = height - 1 | |
| 396 | end | |
| 397 | height = heightMax | |
| 398 | end | |
| 399 | ||
| 400 | function rightWalk() | |
| 401 | right() | |
| 402 | moveForward() | |
| 403 | digAbove() | |
| 404 | digBelow() | |
| 405 | while height > 0 do | |
| 406 | upBreak() | |
| 407 | height = height - 1 | |
| 408 | end | |
| 409 | height = heightMax | |
| 410 | while height > 0 do | |
| 411 | moveDown() | |
| 412 | height = height - 1 | |
| 413 | end | |
| 414 | height = heightMax | |
| 415 | end | |
| 416 | ||
| 417 | function goto(xHome, zHome, yHome) | |
| 418 | while yHome < yCurrent do | |
| 419 | moveDown() | |
| 420 | end | |
| 421 | while yHome > yCurrent do | |
| 422 | moveUp() | |
| 423 | end | |
| 424 | if xHome < xCurrent then | |
| 425 | look("west")
| |
| 426 | while xHome < xCurrent do | |
| 427 | moveForward() | |
| 428 | end | |
| 429 | end | |
| 430 | if xHome > xCurrent then | |
| 431 | look("east")
| |
| 432 | while xHome > xCurrent do | |
| 433 | moveForward() | |
| 434 | end | |
| 435 | end | |
| 436 | if zHome < zCurrent then | |
| 437 | look("north")
| |
| 438 | while zHome < zCurrent do | |
| 439 | moveForward() | |
| 440 | end | |
| 441 | end | |
| 442 | if zHome > zCurrent then | |
| 443 | look("south")
| |
| 444 | while zHome > zCurrent do | |
| 445 | moveForward() | |
| 446 | end | |
| 447 | end | |
| 448 | while not(orientation == startDirection) do | |
| 449 | right() | |
| 450 | end | |
| 451 | end | |
| 452 | ||
| 453 | function dropItems() | |
| 454 | turtle.select(16) | |
| 455 | selectedSlot = 16 | |
| 456 | while not(selectedSlot == 1) do | |
| 457 | turtle.drop() | |
| 458 | selectedSlot = selectedSlot - 1 | |
| 459 | turtle.select(selectedSlot) | |
| 460 | end | |
| 461 | end | |
| 462 | ||
| 463 | function lookLast() | |
| 464 | while not(orientation == orientationLast) do | |
| 465 | right() | |
| 466 | end | |
| 467 | end | |
| 468 | ||
| 469 | function dropOff() | |
| 470 | xBlackcurrant = xCurrent | |
| 471 | zBlackcurrant = zCurrent | |
| 472 | yBlackcurrant = yCurrent | |
| 473 | orientationLast = orientation | |
| 474 | turtle.select(16) | |
| 475 | if turtle.getItemCount() > 0 then | |
| 476 | print("Going to Drop Off")
| |
| 477 | goto(xHome, zHome, yHome) | |
| 478 | dropItems() | |
| 479 | goto(xBlackcurrant, zBlackcurrant, yBlackcurrant) | |
| 480 | lookLast() | |
| 481 | elseif turtle.getItemCount() == 0 then | |
| 482 | turtle.select(1) | |
| 483 | end | |
| 484 | end | |
| 485 | ||
| 486 | while true do | |
| 487 | if lengthCurrent > 0 and ending == false then | |
| 488 | runStartup() | |
| 489 | dropOff() | |
| 490 | torchCheck() | |
| 491 | fuelCheck() | |
| 492 | moveForward() | |
| 493 | digAbove() | |
| 494 | digBelow() | |
| 495 | while height > 0 do | |
| 496 | upBreak() | |
| 497 | height = height - 1 | |
| 498 | end | |
| 499 | height = heightMax | |
| 500 | while height > 0 do | |
| 501 | moveDown() | |
| 502 | height = height - 1 | |
| 503 | end | |
| 504 | height = heightMax | |
| 505 | placeTorch = placeTorch - 1 | |
| 506 | lengthCurrent = lengthCurrent - 1 | |
| 507 | if placeTorch <= 0 then | |
| 508 | placeTorch = 10 | |
| 509 | turtle.placeDown() | |
| 510 | end | |
| 511 | end | |
| 512 | if lengthCurrent <= 0 and turn == 1 and width > 0 then | |
| 513 | width = width - 1 | |
| 514 | if width > 0 then | |
| 515 | rightDig() | |
| 516 | lengthCurrent = lengthMax | |
| 517 | turn = 2 | |
| 518 | print("Turned Right")
| |
| 519 | end | |
| 520 | end | |
| 521 | if lengthCurrent <= 0 and turn == 2 and width > 0 then | |
| 522 | width = width - 1 | |
| 523 | if width > 0 then | |
| 524 | leftDig() | |
| 525 | lengthCurrent = lengthMax | |
| 526 | turn = 1 | |
| 527 | print("Turned Left")
| |
| 528 | end | |
| 529 | end | |
| 530 | if width <= 0 then | |
| 531 | turnLast = turn | |
| 532 | turn = 3 | |
| 533 | ending = true | |
| 534 | end | |
| 535 | if width <= 0 and turn == 3 and ending == true then | |
| 536 | print("Final Walk Home")
| |
| 537 | goto(xHome, zHome, yHome) | |
| 538 | kill = true | |
| 539 | turn = 4 | |
| 540 | end | |
| 541 | if kill == true then | |
| 542 | print("Killing the Program")
| |
| 543 | error() | |
| 544 | end | |
| 545 | end | |
| 546 |