SHOW:
|
|
- or go back to the newest paste.
| 1 | -- This Version | |
| 2 | -- 2.13 10/11/2014 | |
| 3 | -- ChangeLogs | |
| 4 | -- 2.04 - Adding Left or Right Support | |
| 5 | -- 2.05 - Changing Lot Code For Some Stable And Cleaner Code | |
| 6 | -- 2.06 - Ops Forget Fuel Chcking Code after rewrtitting | |
| 7 | -- 2.07 - Woops My Bad i wrote back() not Back() | |
| 8 | -- 2.08 - Fixing Imputs | |
| 9 | -- 2.09 - Forget That i change remove line of code since i use local function now | |
| 10 | -- 2.10 - Minor error with back that it leave one block in wall | |
| 11 | -- Change: Torch spacing to 8 from 10 | |
| 12 | -- 2.11 - Change: Right to left and Left to Right better understand | |
| 13 | -- 2.12 - Add Stop Code when item are gone | |
| 14 | -- 2.13 - i made big mistake i forget to end to new stop code | |
| 15 | -- ToDoList | |
| 16 | -- Add Code to place torch each time it starts | |
| 17 | -- Add Fuel Code so can know almost how much fuel you need | |
| 18 | -- Add second fuel slot if you go allout diggin | |
| 19 | -- Mabye add code that make turtle make new line of tunnels | |
| 20 | ||
| 21 | --Local | |
| 22 | local distance = 0 -- How Far Did User Pick | |
| 23 | local onlight = 0 -- When to Place Torch | |
| 24 | local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch) | |
| 25 | local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest) | |
| 26 | local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel) | |
| 27 | local MD = 3 -- How Many Blocks Apart From Each Mine | |
| 28 | local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count | |
| 29 | local Fuel = 0 -- if 2 then it is unlimited no fuel needed | |
| 30 | local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0 | |
| 31 | local Error = 0 -- 0 = No Error and 1 = Error | |
| 32 | local Way = 0 -- 0 = Left and 1 = Right | |
| 33 | ||
| 34 | --Checking | |
| 35 | local function Check() | |
| 36 | if torch == 0 then | |
| 37 | print("There are no torch's in Turtle")
| |
| 38 | Error = 1 | |
| 39 | else | |
| 40 | print("There are torch's in turtle")
| |
| 41 | end | |
| 42 | if chest == 0 then | |
| 43 | print("there are no chests")
| |
| 44 | Error = 1 | |
| 45 | else | |
| 46 | print("There are chest in turtle")
| |
| 47 | end | |
| 48 | if ItemFuel == 0 then | |
| 49 | print("No Fuel Items")
| |
| 50 | error = 1 | |
| 51 | else | |
| 52 | print("there is fuel")
| |
| 53 | end | |
| 54 | repeat | |
| 55 | if turtle.getFuelLevel() == "unlimited" then | |
| 56 | print("NO NEED FOR FUEL")
| |
| 57 | Needfuel = 0 | |
| 58 | elseif turtle.getFuelLevel() < 100 then | |
| 59 | turtle.select(3) | |
| 60 | turtle.refuel(1) | |
| 61 | Needfuel = 1 | |
| 62 | ItemFuel = ItemFuel - 1 | |
| 63 | elseif NeedFuel == 1 then | |
| 64 | Needfuel = 0 | |
| 65 | end | |
| 66 | until NeedFuel == 0 | |
| 67 | end | |
| 68 | ||
| 69 | -- Recheck if user forget something turtle will check after 15 sec | |
| 70 | local function Recheck() | |
| 71 | torch = turtle.getItemCount(1) | |
| 72 | chest = turtle.getItemCount(2) | |
| 73 | ItemFuel = turtle.getItemCount(3) | |
| 74 | Error = 0 | |
| 75 | end | |
| 76 | ||
| 77 | --Mining | |
| 78 | local function ForwardM() | |
| 79 | repeat | |
| 80 | if turtle.detect() then | |
| 81 | turtle.dig() | |
| 82 | end | |
| 83 | if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance | |
| 84 | TF = TF - 1 | |
| 85 | onlight = onlight + 1 | |
| 86 | end | |
| 87 | if turtle.detectUp() then | |
| 88 | turtle.digUp() | |
| 89 | end | |
| 90 | turtle.select(4) | |
| 91 | turtle.placeDown() | |
| 92 | if onlight == 8 then -- Every 10 Block turtle place torch | |
| 93 | if torch > 0 then | |
| 94 | turtle.turnLeft() | |
| 95 | turtle.turnLeft() | |
| 96 | turtle.select(1) | |
| 97 | turtle.place() | |
| 98 | turtle.turnLeft() | |
| 99 | turtle.turnLeft() | |
| 100 | torch = torch - 1 | |
| 101 | onlight = onlight - 8 | |
| 102 | else | |
| 103 | print("turtle run out of torchs")
| |
| 104 | os.shutdown() | |
| 105 | end | |
| 106 | end | |
| 107 | if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest | |
| 108 | if chest > 0 then | |
| 109 | turtle.select(2) | |
| 110 | turtle.digDown() | |
| 111 | turtle.placeDown() | |
| 112 | chest = chest - 1 | |
| 113 | for slot = 5, 16 do | |
| 114 | turtle.select(slot) | |
| 115 | turtle.dropDown() | |
| 116 | sleep(1.5) | |
| 117 | end | |
| 118 | turtle.select(5) | |
| 119 | else | |
| 120 | print("turtle run out of chest")
| |
| 121 | os.shutdown() | |
| 122 | end | |
| 123 | end | |
| 124 | repeat | |
| 125 | if turtle.getFuelLevel() == "unlimited" then | |
| 126 | print("NO NEED FOR FUEL")
| |
| 127 | Needfuel = 0 | |
| 128 | elseif turtle.getFuelLevel() < 100 then | |
| 129 | turtle.select(3) | |
| 130 | turtle.refuel(1) | |
| 131 | Needfuel = 1 | |
| 132 | ItemFuel = ItemFuel - 1 | |
| 133 | elseif ItemFuel == 0 then | |
| 134 | print("turtle run out of fuel")
| |
| 135 | os.shutdown() | |
| 136 | elseif NeedFuel == 1 then | |
| 137 | Needfuel = 0 | |
| 138 | end | |
| 139 | until NeedFuel == 0 | |
| 140 | until TF == 0 | |
| 141 | end | |
| 142 | ||
| 143 | --Warm Up For Back Program | |
| 144 | local function WarmUpForBackProgram() -- To make turn around so it can go back | |
| 145 | turtle.turnLeft() | |
| 146 | turtle.turnLeft() | |
| 147 | turtle.up() | |
| 148 | end | |
| 149 | ||
| 150 | --Back Program | |
| 151 | local function Back() | |
| 152 | repeat | |
| 153 | if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance | |
| 154 | TB = TB - 1 | |
| 155 | end | |
| 156 | if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it | |
| 157 | if TB ~= 0 then | |
| 158 | turtle.dig() | |
| 159 | end | |
| 160 | end | |
| 161 | until TB == 0 | |
| 162 | end | |
| 163 | ||
| 164 | -- Multimines Program | |
| 165 | local function MultiMines() | |
| 166 | if Way == 1 then | |
| 167 | turtle.turnLeft() | |
| 168 | turtle.down() | |
| 169 | else | |
| 170 | turtle.turnRight() | |
| 171 | turtle.down() | |
| 172 | end | |
| 173 | repeat | |
| 174 | if turtle.detect() then | |
| 175 | turtle.dig() | |
| 176 | end | |
| 177 | if turtle.forward() then | |
| 178 | MD = MD - 1 | |
| 179 | end | |
| 180 | if turtle.detectUp() then | |
| 181 | turtle.digUp() | |
| 182 | end | |
| 183 | until MD == 0 | |
| 184 | if Way == 1 then | |
| 185 | turtle.turnLeft() | |
| 186 | else | |
| 187 | turtle.turnRight() | |
| 188 | end | |
| 189 | if MineTimes == 0 then | |
| 190 | print("Turtle is done")
| |
| 191 | else | |
| 192 | MineTimes = MineTimes - 1 | |
| 193 | end | |
| 194 | end | |
| 195 | ||
| 196 | -- Restart | |
| 197 | local function Restart() | |
| 198 | TF = distance | |
| 199 | TB = distance | |
| 200 | MD = 3 | |
| 201 | onlight = 0 | |
| 202 | end | |
| 203 | ||
| 204 | -- Starting | |
| 205 | function Start() | |
| 206 | repeat | |
| 207 | ForwardM() | |
| 208 | WarmUpForBackProgram() | |
| 209 | Back() | |
| 210 | MultiMines() | |
| 211 | Restart() | |
| 212 | until MineTimes == 0 | |
| 213 | end | |
| 214 | ||
| 215 | -- Start | |
| 216 | print("Hi There Welcome to Mining Turtle Program")
| |
| 217 | print("How Far Will Turtle Go")
| |
| 218 | input = io.read() | |
| 219 | distance = tonumber(input) | |
| 220 | TF = distance | |
| 221 | TB = distance | |
| 222 | print("Left or Right")
| |
| 223 | print("0 = Left and 1 = Right")
| |
| 224 | input2 = io.read() | |
| 225 | Way = tonumber(input2) | |
| 226 | print("How Many Times")
| |
| 227 | input3 = io.read() | |
| 228 | MineTimes = tonumber(input3) | |
| 229 | Check() | |
| 230 | if Error == 1 then | |
| 231 | repeat | |
| 232 | sleep(10) | |
| 233 | Recheck() | |
| 234 | Check() | |
| 235 | until Error == 0 | |
| 236 | end | |
| 237 | Start() |