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