SHOW:
|
|
- or go back to the newest paste.
| 1 | ----Quarry Bot Redux---- | |
| 2 | ||
| 3 | --Variables-- | |
| 4 | ||
| 5 | t = turtle | |
| 6 | ||
| 7 | --Functions-- | |
| 8 | ||
| 9 | function f() | |
| 10 | if t.detect() then | |
| 11 | t.dig() | |
| 12 | t.forward() | |
| 13 | else | |
| 14 | t.forward() | |
| 15 | end | |
| 16 | end | |
| 17 | function d() | |
| 18 | if t.detectDown() then | |
| 19 | t.digDown() | |
| 20 | t.down() | |
| 21 | else | |
| 22 | t.down() | |
| 23 | end | |
| 24 | end | |
| 25 | ||
| 26 | function refuel() | |
| 27 | if t.getFuelLevel() == 0 then | |
| 28 | pleaseRefuel() | |
| 29 | end | |
| 30 | end | |
| 31 | function store() | |
| 32 | if t.getItemCount(16) > 0 then | |
| 33 | pleaseStore() | |
| 34 | end | |
| 35 | end | |
| 36 | ||
| 37 | function pleaseRefuel() | |
| 38 | t.select(1) | |
| 39 | t.digUp() | |
| 40 | t.placeUp() | |
| 41 | t.suckUp() | |
| 42 | t.refuel() | |
| 43 | t.digUp() | |
| 44 | end | |
| 45 | function pleaseStore() | |
| 46 | - | num = num + 1 |
| 46 | + | |
| 47 | t.digUp() | |
| 48 | - | t.select(2) |
| 48 | + | |
| 49 | num = 3 | |
| 50 | while num < 17 do | |
| 51 | t.select(num) | |
| 52 | t.dropUp() | |
| 53 | num = num + 1 | |
| 54 | end | |
| 55 | t.select(2) | |
| 56 | t.digUp() | |
| 57 | end | |
| 58 | ||
| 59 | - | dot = true |
| 59 | + | |
| 60 | refuel() | |
| 61 | store() | |
| 62 | end | |
| 63 | ||
| 64 | - | z = z - 1 |
| 64 | + | function layer() |
| 65 | x = 16 | |
| 66 | - | if dot then |
| 66 | + | |
| 67 | - | t.turnRight() |
| 67 | + | dot = true |
| 68 | - | f() |
| 68 | + | |
| 69 | - | t.turnRight() |
| 69 | + | |
| 70 | - | dot = not dot |
| 70 | + | |
| 71 | - | else |
| 71 | + | |
| 72 | - | t.turnLeft() |
| 72 | + | z = z - 1 |
| 73 | - | if not (x == 2) then |
| 73 | + | |
| 74 | - | f() |
| 74 | + | if dot then |
| 75 | - | end |
| 75 | + | t.turnRight() |
| 76 | - | t.turnLeft() |
| 76 | + | if not (x == 2) then |
| 77 | - | dot = not dot |
| 77 | + | f() |
| 78 | - | end |
| 78 | + | end |
| 79 | - | z = 16 |
| 79 | + | t.turnRight() |
| 80 | - | x = x - 1 |
| 80 | + | dot = not dot |
| 81 | else | |
| 82 | t.turnLeft() | |
| 83 | if not (x == 2) then | |
| 84 | f() | |
| 85 | - | function downward() |
| 85 | + | end |
| 86 | t.turnLeft() | |
| 87 | dot = not dot | |
| 88 | end | |
| 89 | - | quarry() |
| 89 | + | z = 16 |
| 90 | x = x - 1 | |
| 91 | end | |
| 92 | d() | |
| 93 | - | downward() |
| 93 | + | |
| 94 | ||
| 95 | function quarry() | |
| 96 | y = io.read() | |
| 97 | y = tonumber(y) | |
| 98 | while y > 0 do | |
| 99 | layer() | |
| 100 | y = y - 1 | |
| 101 | end | |
| 102 | end | |
| 103 | ||
| 104 | quarry() |