SHOW:
|
|
- or go back to the newest paste.
| 1 | - | hOst = false |
| 1 | + | heading = 1 |
| 2 | - | hDown = false |
| 2 | + | |
| 3 | - | hNord = true |
| 3 | + | |
| 4 | ||
| 5 | tgted = false | |
| 6 | tgt = vector.new(0,0,0) | |
| 7 | ||
| 8 | itmQ = 0 | |
| 9 | ||
| 10 | waypoints = {}
| |
| 11 | waypoints['dockUnl'] = vector.new(-2,0,2) | |
| 12 | waypoints['unload'] = vector.new(-2,0,1) | |
| 13 | ||
| 14 | function moveToTgt() | |
| 15 | if pos.x > tgt.x then | |
| 16 | - | function chngHBool(Int) |
| 16 | + | |
| 17 | end | |
| 18 | - | hOst = swapBool(hOst) |
| 18 | + | |
| 19 | ||
| 20 | - | hDown = swapBool(hDown) |
| 20 | + | function move(Int, Bool) |
| 21 | if (Int == 1) then | |
| 22 | - | hNord = swapBool(hNord) |
| 22 | + | |
| 23 | end | |
| 24 | end | |
| 25 | ||
| 26 | function rotB(Bool) | |
| 27 | if Bool then | |
| 28 | - | if hOst then |
| 28 | + | |
| 29 | heading = heading + 1 | |
| 30 | - | else |
| 30 | + | |
| 31 | turtle.turnLeft() | |
| 32 | heading = heading - 1 | |
| 33 | end | |
| 34 | - | if hDown then |
| 34 | + | if heading > 4 then |
| 35 | heading = 1 | |
| 36 | - | else |
| 36 | + | elseif heading < 1 then |
| 37 | heading = 4 | |
| 38 | end | |
| 39 | end | |
| 40 | - | if hNord then |
| 40 | + | |
| 41 | function rot(Int) | |
| 42 | - | else |
| 42 | + | while Int ~= heading do |
| 43 | - | pos.z = pos.z - 1 |
| 43 | + | |
| 44 | heading = heading + 1 | |
| 45 | if heading > 4 then | |
| 46 | heading = 1 | |
| 47 | elseif heading < 1 then | |
| 48 | heading = 4 | |
| 49 | end | |
| 50 | end | |
| 51 | end | |
| 52 | ||
| 53 | function swapBool(Bool) | |
| 54 | if Bool then | |
| 55 | return false | |
| 56 | else | |
| 57 | - | function Fwd(Int, Bool) |
| 57 | + | |
| 58 | end | |
| 59 | end | |
| 60 | ||
| 61 | function chngCoord(Int) | |
| 62 | - | if Bool then |
| 62 | + | |
| 63 | - | chngCoord(3) |
| 63 | + | |
| 64 | elseif Int == 2 then | |
| 65 | - | chngCoord(1) |
| 65 | + | |
| 66 | elseif Int == 3 then | |
| 67 | pos.z = pos.z - 1 | |
| 68 | elseif Int == 4 then | |
| 69 | pos.x = pos.x - 1 | |
| 70 | elseif Int == 5 then | |
| 71 | pos.y = pos.y - 1 | |
| 72 | elseif Int == 6 then | |
| 73 | pos.y = pos.y + 1 | |
| 74 | - | Fwd(1,false) |
| 74 | + | |
| 75 | end | |
| 76 | - | chngHBool(3) |
| 76 | + | |
| 77 | function ChkFuel() | |
| 78 | if turtle.getFuelLevel() == 0 then | |
| 79 | turtle.select(1) | |
| 80 | - | Fwd(1,false) |
| 80 | + | |
| 81 | print('Dozapravke na ',pos.x, "x",pos.y, "x",pos.z)
| |
| 82 | - | chngHBool(3) |
| 82 | + | |
| 83 | end | |
| 84 | end | |
| 85 | ||
| 86 | function Fwd(Int) | |
| 87 | for a = 1, Int do | |
| 88 | turtle.dig() | |
| 89 | ChkFuel() | |
| 90 | - | chngCoord(2) |
| 90 | + | |
| 91 | - | turtle.turnLeft() |
| 91 | + | chngCoord(heading) |
| 92 | - | turtle.turnLeft() |
| 92 | + | |
| 93 | - | chngHBool(3) |
| 93 | + | |
| 94 | - | chngHBool(1) |
| 94 | + | |
| 95 | ||
| 96 | function Turn(Bool) | |
| 97 | if Bool then | |
| 98 | rotB(true) | |
| 99 | Fwd(1) | |
| 100 | rotB(true) | |
| 101 | return false | |
| 102 | else | |
| 103 | rotB(false) | |
| 104 | - | Fwd(1,true) |
| 104 | + | Fwd(1) |
| 105 | - | turtle.turnLeft() |
| 105 | + | rotB(false) |
| 106 | - | Fwd(mX/2,false) |
| 106 | + | |
| 107 | - | chngHBool(1) |
| 107 | + | |
| 108 | - | turtle.turnRight() |
| 108 | + | |
| 109 | ||
| 110 | function down() | |
| 111 | turtle.digDown() | |
| 112 | turtle.down() | |
| 113 | chngCoord(5) | |
| 114 | - | chngCoord(2) |
| 114 | + | rotB(false) |
| 115 | rotB(false) | |
| 116 | - | chngHBool(2) |
| 116 | + | |
| 117 | ||
| 118 | print('Vvedite Shiriny')
| |
| 119 | mX = tonumber(read()) | |
| 120 | print('Vvedite glubinu')
| |
| 121 | mY = tonumber(read()) | |
| 122 | ||
| 123 | print(' Starting at ',pos.x, "x",pos.y, "x",pos.z)
| |
| 124 | ||
| 125 | Fwd(1) | |
| 126 | rotB(false) | |
| 127 | Fwd(mX/2) | |
| 128 | rotB(true) | |
| 129 | - | Fwd(mX - 1,true) |
| 129 | + | |
| 130 | ||
| 131 | - | Fwd(mX,true) |
| 131 | + | |
| 132 | turtle.digUp() | |
| 133 | turtle.up() | |
| 134 | chngCoord(6) | |
| 135 | end | |
| 136 | ||
| 137 | ||
| 138 | print(' Dig down at ',pos.x, "x",pos.y, "x",pos.z)
| |
| 139 | - | print('Begin dig up, steps up = ', mY + 3, "\n ", pos.x, "x",pos.y, "x",pos.z)
|
| 139 | + | |
| 140 | turn = true | |
| 141 | - | chngHBool(2) |
| 141 | + | |
| 142 | ||
| 143 | for y = 1, mY+3 do | |
| 144 | if y > 1 then | |
| 145 | - | chngCoord(2) |
| 145 | + | |
| 146 | end | |
| 147 | for x = 1, mX do | |
| 148 | if mX > 1 then | |
| 149 | Fwd(mX - 1) | |
| 150 | else | |
| 151 | Fwd(mX) | |
| 152 | end | |
| 153 | if x ~= mX then | |
| 154 | turn = Turn(turn) | |
| 155 | end | |
| 156 | end | |
| 157 | end | |
| 158 | ||
| 159 | print('Begin dig up, steps up = ', mY, "\n ", pos.x, "x",pos.y, "x",pos.z)
| |
| 160 | ||
| 161 | ||
| 162 | for b=1, mY do | |
| 163 | turtle.digUp() | |
| 164 | turtle.up() | |
| 165 | chngCoord(6) | |
| 166 | end | |
| 167 | print('Ending operation ', pos.x, "x",pos.y, "x",pos.z) |