diff --git a/miningTurtle.lua b/miningTurtle.lua index bb7ff6d..a704ff9 100644 --- a/miningTurtle.lua +++ b/miningTurtle.lua @@ -98,12 +98,6 @@ if not modem or not selfName then return fatal("[ERR] No wired modem found!\n Attach a wired modem to the turtle\n and connect it to the network.") end --- Wrap our own inventory peripheral for pushItems -local selfInv = peripheral.wrap(selfName) -if not selfInv then - return fatal("[ERR] Cannot wrap own peripheral: " .. selfName .. "\n Make sure the wired modem is connected.") -end - print("[OK] Modem: " .. modemSide) print("[OK] Network name: " .. selfName) print("[OK] Mine interval: " .. MINE_INTERVAL .. "s") @@ -128,6 +122,9 @@ end ------------------------------------------------- -- Dump inventory into networked storage +-- Uses pull approach: wrap the remote chest and call +-- chest.pullItems(selfName, slot) — avoids needing +-- to wrap the turtle's own peripheral. ------------------------------------------------- local function dumpInventory() @@ -141,11 +138,14 @@ local function dumpInventory() for slot = 1, 16 do if slot ~= FUEL_SLOT and turtle.getItemCount(slot) > 0 then for _, chestName in ipairs(chests) do - local ok, n = pcall(selfInv.pushItems, chestName, slot) - if ok and n and n > 0 then - totalPushed = totalPushed + n - if turtle.getItemCount(slot) == 0 then - break -- slot empty, move to next + local chest = peripheral.wrap(chestName) + if chest and chest.pullItems then + local ok, n = pcall(chest.pullItems, selfName, slot) + if ok and n and n > 0 then + totalPushed = totalPushed + n + if turtle.getItemCount(slot) == 0 then + break -- slot empty, move to next + end end end end