turtle_deployer.lua
707 lines ยท 22.1 KB
eHydra Turtle Deployment System
Copy & run
wget https://perlytiara.github.io/turtles.tips/raw/programs/perlytiara/eHydra_wip/turtle_deployer.lua
| 1 | -- eHydra Turtle Deployment System |
| 2 | -- Advanced turtle placement and configuration |
| 3 | |
| 4 | local SLOT_COUNT = 16 |
| 5 | |
| 6 | -- Improved inventory scanning functions |
| 7 | local function getItemIndex(itemName) |
| 8 | for slot = 1, SLOT_COUNT do |
| 9 | local item = turtle.getItemDetail(slot) |
| 10 | if item and item.name == itemName then |
| 11 | return slot |
| 12 | end |
| 13 | end |
| 14 | return nil |
| 15 | end |
| 16 | |
| 17 | local function findItemsInInventory(itemPattern) |
| 18 | local items = {} |
| 19 | for slot = 1, SLOT_COUNT do |
| 20 | local item = turtle.getItemDetail(slot) |
| 21 | if item and (item.name == itemPattern or item.name:find(itemPattern)) then |
| 22 | table.insert(items, {slot = slot, name = item.name, count = item.count}) |
| 23 | end |
| 24 | end |
| 25 | return items |
| 26 | end |
| 27 | |
| 28 | local function scanInventoryForDeployment() |
| 29 | print("๐ Scanning inventory for deployment items...") |
| 30 | |
| 31 | local inventory = { |
| 32 | turtles = findItemsInInventory("turtle"), |
| 33 | diskDrives = findItemsInInventory("disk_drive"), |
| 34 | disks = findItemsInInventory("floppy_disk"), |
| 35 | fuel = findItemsInInventory("coal"), |
| 36 | enderChests = findItemsInInventory("ender") |
| 37 | } |
| 38 | |
| 39 | print("๐ฆ Inventory scan results:") |
| 40 | print(" ๐ข Turtles: " .. #inventory.turtles) |
| 41 | print(" ๐พ Disk drives: " .. #inventory.diskDrives) |
| 42 | print(" ๐ฟ Disks: " .. #inventory.disks) |
| 43 | print(" โฝ Fuel items: " .. #inventory.fuel) |
| 44 | print(" ๐ฆ Ender chests: " .. #inventory.enderChests) |
| 45 | |
| 46 | return inventory |
| 47 | end |
| 48 | |
| 49 | local function selectBestTurtle(inventory, preferredType) |
| 50 | if #inventory.turtles == 0 then |
| 51 | return nil, "No turtles found in inventory" |
| 52 | end |
| 53 | |
| 54 | -- Priority order for turtle selection |
| 55 | local priorities = { |
| 56 | "advancedperipherals:chunky_turtle", |
| 57 | "computercraft:turtle_advanced", |
| 58 | "computercraft:turtle_normal" |
| 59 | } |
| 60 | |
| 61 | -- Try to find preferred type first |
| 62 | if preferredType then |
| 63 | for _, turtleInfo in ipairs(inventory.turtles) do |
| 64 | if turtleInfo.name:find(preferredType) then |
| 65 | return turtleInfo, nil |
| 66 | end |
| 67 | end |
| 68 | end |
| 69 | |
| 70 | -- Fall back to priority order |
| 71 | for _, priority in ipairs(priorities) do |
| 72 | for _, turtleInfo in ipairs(inventory.turtles) do |
| 73 | if turtleInfo.name == priority then |
| 74 | return turtleInfo, nil |
| 75 | end |
| 76 | end |
| 77 | end |
| 78 | |
| 79 | -- Return first available turtle |
| 80 | return inventory.turtles[1], nil |
| 81 | end |
| 82 | |
| 83 | local function createStartupDisk(program, parameters, diskSlot) |
| 84 | turtle.select(diskSlot) |
| 85 | |
| 86 | -- Create startup file on disk |
| 87 | if fs.exists("disk/startup") then |
| 88 | fs.delete("disk/startup") |
| 89 | end |
| 90 | |
| 91 | local startupFile = fs.open("disk/startup", "w") |
| 92 | if not startupFile then |
| 93 | return false, "Could not create startup file on disk" |
| 94 | end |
| 95 | |
| 96 | -- Write startup script that copies programs and sets up turtle |
| 97 | startupFile.write(string.format([[ |
| 98 | -- eHydra Turtle Startup v2.0 |
| 99 | print("๐ข eHydra Turtle Starting...") |
| 100 | |
| 101 | -- Copy eHydra client to turtle |
| 102 | if fs.exists("disk/turtle_client") then |
| 103 | fs.copy("disk/turtle_client", "turtle_client") |
| 104 | fs.copy("disk/turtle_client", "startup") -- Make it permanent startup |
| 105 | print("โ eHydra client installed") |
| 106 | else |
| 107 | print("โ ๏ธ eHydra client not found on disk") |
| 108 | end |
| 109 | |
| 110 | -- Copy target program to turtle if specified |
| 111 | if "%s" ~= "turtle_client" then |
| 112 | if fs.exists("disk/%s") then |
| 113 | fs.copy("disk/%s", "%s") |
| 114 | print("โ Program copied: %s") |
| 115 | else |
| 116 | print("โ ๏ธ Program %s not found on disk") |
| 117 | end |
| 118 | end |
| 119 | |
| 120 | -- Send deployment confirmation |
| 121 | local modem = peripheral.find("modem") |
| 122 | if modem then |
| 123 | rednet.open(peripheral.getName(modem)) |
| 124 | rednet.broadcast("TURTLE_DEPLOYED", "ehydra") |
| 125 | print("๐ก Deployment confirmed") |
| 126 | end |
| 127 | |
| 128 | -- Initialize GPS location |
| 129 | local x, y, z = gps.locate(2, false) |
| 130 | if x then |
| 131 | print("๐ GPS: " .. x .. ", " .. y .. ", " .. z) |
| 132 | end |
| 133 | |
| 134 | -- Start the eHydra client (which will listen for commands) |
| 135 | print("๐ Starting eHydra turtle client...") |
| 136 | if fs.exists("turtle_client") then |
| 137 | shell.run("turtle_client") |
| 138 | else |
| 139 | print("โ eHydra client not found, running target program directly") |
| 140 | if "%s" ~= "" and fs.exists("%s") then |
| 141 | shell.run("%s", "%s") |
| 142 | else |
| 143 | print("โ No programs available to run") |
| 144 | end |
| 145 | end |
| 146 | ]], program, program, program, program, program, program, program, parameters or "", program)) |
| 147 | |
| 148 | startupFile.close() |
| 149 | |
| 150 | -- Also copy the turtle client program to the disk |
| 151 | if fs.exists("turtle_client.lua") then |
| 152 | if fs.exists("disk/turtle_client") then |
| 153 | fs.delete("disk/turtle_client") |
| 154 | end |
| 155 | fs.copy("turtle_client.lua", "disk/turtle_client") |
| 156 | print("โ eHydra client added to disk") |
| 157 | else |
| 158 | print("โ ๏ธ turtle_client.lua not found - turtle will have limited functionality") |
| 159 | end |
| 160 | |
| 161 | return true, nil |
| 162 | end |
| 163 | |
| 164 | local function setupTurtleDisk(inventory, program, parameters) |
| 165 | if #inventory.diskDrives == 0 or #inventory.disks == 0 then |
| 166 | return nil, "Disk drive or floppy disk missing from inventory" |
| 167 | end |
| 168 | |
| 169 | local diskDriveSlot = inventory.diskDrives[1].slot |
| 170 | local diskSlot = inventory.disks[1].slot |
| 171 | |
| 172 | -- Select and place disk drive |
| 173 | turtle.select(diskDriveSlot) |
| 174 | turtle.placeDown() |
| 175 | |
| 176 | -- Insert disk |
| 177 | turtle.select(diskSlot) |
| 178 | turtle.dropDown() |
| 179 | |
| 180 | -- Wait for disk to be recognized |
| 181 | sleep(1) |
| 182 | |
| 183 | if not fs.exists("disk") then |
| 184 | return nil, "Disk not mounted properly" |
| 185 | end |
| 186 | |
| 187 | -- Create startup disk |
| 188 | local success, err = createStartupDisk(program, parameters, diskSlot) |
| 189 | if not success then |
| 190 | return nil, err |
| 191 | end |
| 192 | |
| 193 | print("โ Startup disk created for program: " .. program) |
| 194 | return diskDriveSlot, nil |
| 195 | end |
| 196 | |
| 197 | local function deployTurtleWithDisk(inventory, direction, preferredType, program, parameters) |
| 198 | -- Scan and select best turtle |
| 199 | local turtleInfo, err = selectBestTurtle(inventory, preferredType) |
| 200 | if not turtleInfo then |
| 201 | print("โ " .. err) |
| 202 | return false |
| 203 | end |
| 204 | |
| 205 | print("๐ฆ Selected: " .. turtleInfo.name .. " from slot " .. turtleInfo.slot) |
| 206 | |
| 207 | -- Setup disk with startup program |
| 208 | local diskDriveSlot, diskErr = setupTurtleDisk(inventory, program or "quarry", parameters) |
| 209 | if not diskDriveSlot then |
| 210 | print("โ Disk setup failed: " .. (diskErr or "unknown error")) |
| 211 | return false |
| 212 | end |
| 213 | |
| 214 | -- Clear space and place turtle |
| 215 | local placeFunction |
| 216 | if direction == "down" then |
| 217 | placeFunction = turtle.placeDown |
| 218 | -- Check for obstruction |
| 219 | while turtle.detectDown() do |
| 220 | print("โ Obstruction below, clearing...") |
| 221 | turtle.digDown() |
| 222 | sleep(0.5) |
| 223 | end |
| 224 | elseif direction == "up" then |
| 225 | placeFunction = turtle.placeUp |
| 226 | while turtle.detectUp() do |
| 227 | print("โ Obstruction above, clearing...") |
| 228 | turtle.digUp() |
| 229 | sleep(0.5) |
| 230 | end |
| 231 | else |
| 232 | placeFunction = turtle.place |
| 233 | while turtle.detect() do |
| 234 | print("โ Obstruction ahead, clearing...") |
| 235 | turtle.dig() |
| 236 | sleep(0.5) |
| 237 | end |
| 238 | end |
| 239 | |
| 240 | -- Place the turtle |
| 241 | turtle.select(turtleInfo.slot) |
| 242 | if placeFunction() then |
| 243 | print("โ Turtle placed successfully") |
| 244 | |
| 245 | -- Turn on the turtle |
| 246 | local turtleDirection = direction == "down" and "bottom" or (direction == "up" and "top" or "front") |
| 247 | peripheral.call(turtleDirection, "turnOn") |
| 248 | print("โ Turtle powered on") |
| 249 | |
| 250 | -- Wait for deployment confirmation |
| 251 | print("โณ Waiting for turtle to boot and send confirmation...") |
| 252 | local modem = peripheral.find("modem") |
| 253 | if modem then |
| 254 | rednet.open(peripheral.getName(modem)) |
| 255 | local senderId, message, protocol = rednet.receive("ehydra", 10) |
| 256 | if message == "TURTLE_DEPLOYED" then |
| 257 | print("โ Turtle deployment confirmed!") |
| 258 | return true |
| 259 | else |
| 260 | print("โ No confirmation received, but turtle may be working") |
| 261 | return true |
| 262 | end |
| 263 | else |
| 264 | print("โ No modem found, cannot confirm deployment") |
| 265 | return true |
| 266 | end |
| 267 | else |
| 268 | print("โ Failed to place turtle") |
| 269 | return false |
| 270 | end |
| 271 | end |
| 272 | |
| 273 | local function configureTurtle(id, config) |
| 274 | print("Configuring turtle " .. id .. "...") |
| 275 | |
| 276 | -- Send configuration |
| 277 | rednet.send(id, { |
| 278 | command = "CONFIG", |
| 279 | fuelLevel = config.fuel or 1000, |
| 280 | program = config.program or "quarry", |
| 281 | autostart = config.autostart or false, |
| 282 | chunkloading = config.chunky or false |
| 283 | }) |
| 284 | |
| 285 | -- Wait for acknowledgment |
| 286 | local senderId, response = rednet.receive(3) |
| 287 | if senderId == id and response and response.status == "CONFIGURED" then |
| 288 | print("โ Turtle " .. id .. " configured") |
| 289 | return true |
| 290 | else |
| 291 | print("โ Configuration may have failed") |
| 292 | return false |
| 293 | end |
| 294 | end |
| 295 | |
| 296 | local function setupWirelessChunkyTurtle() |
| 297 | print("Setting up Advanced Wireless Chunky Turtle...") |
| 298 | print("============================================") |
| 299 | |
| 300 | local inventory = scanInventoryForDeployment() |
| 301 | |
| 302 | -- Check requirements |
| 303 | if #inventory.turtles == 0 then |
| 304 | print("โ No turtles found in inventory") |
| 305 | print("Required: At least 1 advanced turtle") |
| 306 | return false |
| 307 | end |
| 308 | |
| 309 | if #inventory.diskDrives == 0 or #inventory.disks == 0 then |
| 310 | print("โ Missing disk drive or floppy disk") |
| 311 | print("Required: 1 disk drive + 1 floppy disk for startup program") |
| 312 | return false |
| 313 | end |
| 314 | |
| 315 | print() |
| 316 | print("Select placement direction:") |
| 317 | print("1. Forward") |
| 318 | print("2. Down") |
| 319 | print("3. Up") |
| 320 | write("Choice [1]: ") |
| 321 | local dirChoice = tonumber(read()) or 1 |
| 322 | |
| 323 | local direction = "forward" |
| 324 | if dirChoice == 2 then direction = "down" |
| 325 | elseif dirChoice == 3 then direction = "up" end |
| 326 | |
| 327 | print() |
| 328 | write("Mining program [quarry]: ") |
| 329 | local program = read() |
| 330 | if program == "" then program = "quarry" end |
| 331 | |
| 332 | write("Program parameters (optional): ") |
| 333 | local parameters = read() |
| 334 | |
| 335 | print() |
| 336 | print("๐ Deploying chunky turtle with disk-based startup...") |
| 337 | |
| 338 | if deployTurtleWithDisk(inventory, direction, "chunky", program, parameters) then |
| 339 | print() |
| 340 | print("๐ Advanced Wireless Chunky Turtle deployed successfully!") |
| 341 | print(" ๐ Program: " .. program) |
| 342 | if parameters and parameters ~= "" then |
| 343 | print(" โ๏ธ Parameters: " .. parameters) |
| 344 | end |
| 345 | print(" ๐ฟ Startup disk configured") |
| 346 | print(" ๐ก Wireless communication enabled") |
| 347 | return true |
| 348 | else |
| 349 | print("โ Deployment failed") |
| 350 | return false |
| 351 | end |
| 352 | end |
| 353 | |
| 354 | local function deployCompleteMiningSetup() |
| 355 | print("Complete Mining Setup Deployment") |
| 356 | print("===============================") |
| 357 | |
| 358 | local inventory = scanInventoryForDeployment() |
| 359 | |
| 360 | -- Check for complete setup requirements |
| 361 | local required = { |
| 362 | {inventory.turtles, "turtles", 1}, |
| 363 | {inventory.diskDrives, "disk drives", 1}, |
| 364 | {inventory.disks, "floppy disks", 1}, |
| 365 | {findItemsInInventory("computer"), "computers", 1}, |
| 366 | {findItemsInInventory("chest"), "chests", 3}, |
| 367 | {findItemsInInventory("coal"), "coal", 32} |
| 368 | } |
| 369 | |
| 370 | local missing = {} |
| 371 | for _, req in ipairs(required) do |
| 372 | local items, name, needed = req[1], req[2], req[3] |
| 373 | local totalCount = 0 |
| 374 | for _, item in ipairs(items) do |
| 375 | totalCount = totalCount + item.count |
| 376 | end |
| 377 | if totalCount < needed then |
| 378 | table.insert(missing, name .. " (need " .. needed .. ", have " .. totalCount .. ")") |
| 379 | end |
| 380 | end |
| 381 | |
| 382 | if #missing > 0 then |
| 383 | print("โ Missing required items for complete setup:") |
| 384 | for _, item in ipairs(missing) do |
| 385 | print(" โข " .. item) |
| 386 | end |
| 387 | print() |
| 388 | print("Required for complete mining setup:") |
| 389 | print(" โข 1+ Advanced turtle") |
| 390 | print(" โข 1+ Disk drive") |
| 391 | print(" โข 1+ Floppy disk") |
| 392 | print(" โข 1+ Computer (for monitoring)") |
| 393 | print(" โข 3+ Chests (coal, storage, spare)") |
| 394 | print(" โข 32+ Coal (for fuel)") |
| 395 | return false |
| 396 | end |
| 397 | |
| 398 | -- Get GPS position |
| 399 | print("๐ Getting GPS position for setup...") |
| 400 | local x, y, z = gps.locate(5, false) |
| 401 | if not x then |
| 402 | print("โ GPS required for automated complete setup") |
| 403 | print("Please ensure GPS satellites are available") |
| 404 | return false |
| 405 | end |
| 406 | |
| 407 | local basePos = {x = math.floor(x), y = math.floor(y), z = math.floor(z)} |
| 408 | print("โ Base position: " .. basePos.x .. ", " .. basePos.y .. ", " .. basePos.z) |
| 409 | |
| 410 | -- Get mining parameters |
| 411 | print() |
| 412 | write("Mining program [quarry]: ") |
| 413 | local program = read() |
| 414 | if program == "" then program = "quarry" end |
| 415 | |
| 416 | write("Mining width [16]: ") |
| 417 | local width = tonumber(read()) or 16 |
| 418 | |
| 419 | write("Mining depth [16]: ") |
| 420 | local depth = tonumber(read()) or 16 |
| 421 | |
| 422 | write("Mining height [10]: ") |
| 423 | local height = tonumber(read()) or 10 |
| 424 | |
| 425 | write("Program parameters (optional): ") |
| 426 | local parameters = read() |
| 427 | |
| 428 | -- Calculate mining area |
| 429 | local area = { |
| 430 | start = {x = basePos.x, y = basePos.y - height, z = basePos.z}, |
| 431 | finish = {x = basePos.x + width - 1, y = basePos.y - 1, z = basePos.z + depth - 1}, |
| 432 | coalChest = {x = basePos.x - 1, y = basePos.y, z = basePos.z - 1}, |
| 433 | storageChest = {x = basePos.x + 1, y = basePos.y, z = basePos.z - 1}, |
| 434 | computer = {x = basePos.x, y = basePos.y + 1, z = basePos.z - 2} |
| 435 | } |
| 436 | |
| 437 | print() |
| 438 | print("๐ Mining Setup Plan:") |
| 439 | print(" ๐ฆ Mining area: " .. width .. "x" .. depth .. "x" .. height) |
| 440 | print(" ๐๏ธ Start: " .. area.start.x .. ", " .. area.start.y .. ", " .. area.start.z) |
| 441 | print(" ๐ End: " .. area.finish.x .. ", " .. area.finish.y .. ", " .. area.finish.z) |
| 442 | print(" โฝ Coal chest: " .. area.coalChest.x .. ", " .. area.coalChest.y .. ", " .. area.coalChest.z) |
| 443 | print(" ๐ฆ Storage: " .. area.storageChest.x .. ", " .. area.storageChest.y .. ", " .. area.storageChest.z) |
| 444 | |
| 445 | print() |
| 446 | write("Deploy complete mining setup? (y/n) [y]: ") |
| 447 | local confirm = string.lower(read()) |
| 448 | if confirm == "n" then |
| 449 | print("Setup cancelled") |
| 450 | return false |
| 451 | end |
| 452 | |
| 453 | print() |
| 454 | print("๐ Deploying complete mining infrastructure...") |
| 455 | |
| 456 | -- Step 1: Place coal chest and fill it |
| 457 | print("โฝ Setting up fuel infrastructure...") |
| 458 | turtle.back() -- Move to coal chest position |
| 459 | turtle.select(findItemsInInventory("chest")[1].slot) |
| 460 | turtle.placeDown() |
| 461 | |
| 462 | -- Fill with coal |
| 463 | local coalItem = findItemsInInventory("coal")[1] |
| 464 | turtle.select(coalItem.slot) |
| 465 | turtle.dropDown(32) |
| 466 | print("โ Coal chest placed and stocked") |
| 467 | |
| 468 | -- Step 2: Place storage chest |
| 469 | print("๐ฆ Setting up storage...") |
| 470 | turtle.forward() |
| 471 | turtle.forward() |
| 472 | turtle.select(findItemsInInventory("chest")[2].slot) |
| 473 | turtle.placeDown() |
| 474 | print("โ Storage chest placed") |
| 475 | |
| 476 | -- Step 3: Place monitoring computer |
| 477 | print("๐ฅ๏ธ Setting up monitoring...") |
| 478 | turtle.back() |
| 479 | turtle.up() |
| 480 | turtle.back() |
| 481 | turtle.select(findItemsInInventory("computer")[1].slot) |
| 482 | turtle.place() |
| 483 | print("โ Monitoring computer placed") |
| 484 | |
| 485 | -- Step 4: Setup mining turtle with complete program |
| 486 | print("๐ข Deploying mining turtle with complete setup...") |
| 487 | turtle.forward() |
| 488 | turtle.down() |
| 489 | |
| 490 | -- Create comprehensive startup disk |
| 491 | local diskDrive = inventory.diskDrives[1] |
| 492 | local disk = inventory.disks[1] |
| 493 | |
| 494 | turtle.select(diskDrive.slot) |
| 495 | turtle.placeUp() |
| 496 | turtle.select(disk.slot) |
| 497 | turtle.dropUp() |
| 498 | |
| 499 | sleep(1) -- Wait for disk to mount |
| 500 | |
| 501 | if fs.exists("disk") then |
| 502 | -- Create advanced mining startup |
| 503 | local startupFile = fs.open("disk/startup", "w") |
| 504 | if startupFile then |
| 505 | startupFile.write(string.format([[ |
| 506 | -- eHydra Complete Mining Operation |
| 507 | print("๐๏ธ eHydra Complete Mining Setup v1.0") |
| 508 | print("====================================") |
| 509 | |
| 510 | -- Configuration |
| 511 | local miningArea = { |
| 512 | start = {x = %d, y = %d, z = %d}, |
| 513 | size = {width = %d, depth = %d, height = %d}, |
| 514 | coalChest = {x = %d, y = %d, z = %d}, |
| 515 | storageChest = {x = %d, y = %d, z = %d} |
| 516 | } |
| 517 | |
| 518 | -- Automated fuel management |
| 519 | local function autoRefuel() |
| 520 | if turtle.getFuelLevel() < 100 then |
| 521 | -- Navigate to coal chest and refuel |
| 522 | print("โฝ Auto-refueling...") |
| 523 | -- Implementation for navigation and refueling |
| 524 | return true |
| 525 | end |
| 526 | return true |
| 527 | end |
| 528 | |
| 529 | -- Automated inventory management |
| 530 | local function autoDeposit() |
| 531 | -- Navigate to storage chest and deposit non-fuel items |
| 532 | print("๐ฆ Auto-depositing...") |
| 533 | return true |
| 534 | end |
| 535 | |
| 536 | -- Status reporting |
| 537 | local function reportStatus(message) |
| 538 | local modem = peripheral.find("modem") |
| 539 | if modem then |
| 540 | rednet.open(peripheral.getName(modem)) |
| 541 | rednet.broadcast({ |
| 542 | id = os.getComputerID(), |
| 543 | status = message, |
| 544 | area = miningArea, |
| 545 | fuel = turtle.getFuelLevel(), |
| 546 | time = os.time() |
| 547 | }, "ehydra_mining") |
| 548 | end |
| 549 | end |
| 550 | |
| 551 | -- Main mining operation |
| 552 | reportStatus("MINING_STARTED") |
| 553 | |
| 554 | -- Copy and run mining program |
| 555 | if fs.exists("disk/%s") then |
| 556 | fs.copy("disk/%s", "%s") |
| 557 | print("โ Program installed: %s") |
| 558 | |
| 559 | -- Start mining with parameters |
| 560 | reportStatus("MINING_ACTIVE") |
| 561 | shell.run("%s", "%s") |
| 562 | |
| 563 | reportStatus("MINING_COMPLETED") |
| 564 | else |
| 565 | print("โ Mining program not found") |
| 566 | reportStatus("ERROR_NO_PROGRAM") |
| 567 | end |
| 568 | ]], |
| 569 | area.start.x, area.start.y, area.start.z, |
| 570 | width, depth, height, |
| 571 | area.coalChest.x, area.coalChest.y, area.coalChest.z, |
| 572 | area.storageChest.x, area.storageChest.y, area.storageChest.z, |
| 573 | program, program, program, program, program, parameters or "" |
| 574 | )) |
| 575 | startupFile.close() |
| 576 | |
| 577 | -- Copy mining program to disk |
| 578 | if fs.exists(program .. ".lua") then |
| 579 | fs.copy(program .. ".lua", "disk/" .. program) |
| 580 | end |
| 581 | end |
| 582 | end |
| 583 | |
| 584 | -- Deploy the mining turtle |
| 585 | local turtleInfo = selectBestTurtle(inventory, "advanced") |
| 586 | turtle.select(turtleInfo.slot) |
| 587 | turtle.place() |
| 588 | peripheral.call("front", "turnOn") |
| 589 | |
| 590 | print() |
| 591 | print("๐ Complete mining setup deployed successfully!") |
| 592 | print("===============================================") |
| 593 | print(" ๐ข Mining turtle: Active with " .. program) |
| 594 | print(" โฝ Coal chest: Stocked and positioned") |
| 595 | print(" ๐ฆ Storage chest: Ready for output") |
| 596 | print(" ๐ฅ๏ธ Monitor computer: Tracking operations") |
| 597 | print(" ๐ก Wireless monitoring: Enabled") |
| 598 | print(" ๐๏ธ Mining area: " .. width .. "x" .. depth .. "x" .. height) |
| 599 | |
| 600 | return true |
| 601 | end |
| 602 | |
| 603 | print("eHydra Turtle Deployer v1.0") |
| 604 | print("===========================") |
| 605 | print() |
| 606 | print("1. Deploy single Advanced Mining Turtle") |
| 607 | print("2. Setup Advanced Wireless Chunky Turtle") |
| 608 | print("3. Deploy Complete Mining Setup (GPS + Infrastructure)") |
| 609 | print("4. List inventory and deployment readiness") |
| 610 | print() |
| 611 | |
| 612 | write("Choice [1-4]: ") |
| 613 | local choice = tonumber(read()) or 1 |
| 614 | |
| 615 | if choice == 1 then |
| 616 | print() |
| 617 | print("Deploy Single Advanced Mining Turtle") |
| 618 | print("===================================") |
| 619 | |
| 620 | local inventory = scanInventoryForDeployment() |
| 621 | |
| 622 | if #inventory.turtles == 0 then |
| 623 | print("โ No turtles found in inventory") |
| 624 | return |
| 625 | end |
| 626 | |
| 627 | write("Mining program [quarry]: ") |
| 628 | local program = read() |
| 629 | if program == "" then program = "quarry" end |
| 630 | |
| 631 | write("Program parameters (optional): ") |
| 632 | local parameters = read() |
| 633 | |
| 634 | if deployTurtleWithDisk(inventory, "down", "advanced", program, parameters) then |
| 635 | print("โ Single mining turtle deployed successfully!") |
| 636 | else |
| 637 | print("โ Deployment failed") |
| 638 | end |
| 639 | |
| 640 | elseif choice == 2 then |
| 641 | print() |
| 642 | setupWirelessChunkyTurtle() |
| 643 | |
| 644 | elseif choice == 3 then |
| 645 | print() |
| 646 | deployCompleteMiningSetup() |
| 647 | |
| 648 | elseif choice == 4 then |
| 649 | print() |
| 650 | local inventory = scanInventoryForDeployment() |
| 651 | |
| 652 | print("๐ Detailed Inventory Report:") |
| 653 | print("============================") |
| 654 | |
| 655 | if #inventory.turtles > 0 then |
| 656 | print("๐ข Turtles:") |
| 657 | for i, turtle in ipairs(inventory.turtles) do |
| 658 | print(" " .. i .. ". " .. turtle.name .. " (slot " .. turtle.slot .. ", count: " .. turtle.count .. ")") |
| 659 | end |
| 660 | end |
| 661 | |
| 662 | if #inventory.diskDrives > 0 then |
| 663 | print("๐พ Disk Drives:") |
| 664 | for i, drive in ipairs(inventory.diskDrives) do |
| 665 | print(" " .. i .. ". " .. drive.name .. " (slot " .. drive.slot .. ", count: " .. drive.count .. ")") |
| 666 | end |
| 667 | end |
| 668 | |
| 669 | if #inventory.disks > 0 then |
| 670 | print("๐ฟ Floppy Disks:") |
| 671 | for i, disk in ipairs(inventory.disks) do |
| 672 | print(" " .. i .. ". " .. disk.name .. " (slot " .. disk.slot .. ", count: " .. disk.count .. ")") |
| 673 | end |
| 674 | end |
| 675 | |
| 676 | if #inventory.fuel > 0 then |
| 677 | print("โฝ Fuel Items:") |
| 678 | for i, fuel in ipairs(inventory.fuel) do |
| 679 | print(" " .. i .. ". " .. fuel.name .. " (slot " .. fuel.slot .. ", count: " .. fuel.count .. ")") |
| 680 | end |
| 681 | end |
| 682 | |
| 683 | if #inventory.enderChests > 0 then |
| 684 | print("๐ฆ Ender Chests:") |
| 685 | for i, chest in ipairs(inventory.enderChests) do |
| 686 | print(" " .. i .. ". " .. chest.name .. " (slot " .. chest.slot .. ", count: " .. chest.count .. ")") |
| 687 | end |
| 688 | end |
| 689 | |
| 690 | -- Show readiness status |
| 691 | print() |
| 692 | print("๐ฆ Deployment Readiness:") |
| 693 | local canDeploy = #inventory.turtles > 0 and #inventory.diskDrives > 0 and #inventory.disks > 0 |
| 694 | if canDeploy then |
| 695 | print("โ Ready for deployment!") |
| 696 | print(" Can deploy: " .. math.min(#inventory.turtles, #inventory.diskDrives, #inventory.disks) .. " turtle(s)") |
| 697 | else |
| 698 | print("โ Not ready for deployment") |
| 699 | if #inventory.turtles == 0 then print(" Missing: Turtles") end |
| 700 | if #inventory.diskDrives == 0 then print(" Missing: Disk drives") end |
| 701 | if #inventory.disks == 0 then print(" Missing: Floppy disks") end |
| 702 | end |
| 703 | |
| 704 | else |
| 705 | print("Invalid choice") |
| 706 | end |
| 707 |