diff --git a/src/brulijam/t-fiboMiner.lua b/src/brulijam/t-fiboMiner.lua index c53b843..de74541 100644 --- a/src/brulijam/t-fiboMiner.lua +++ b/src/brulijam/t-fiboMiner.lua @@ -55,51 +55,34 @@ end local function getState() if not fs.exists "brulijam/files/state-t-fiboMiner.txt" then - turtleState = {} - turtleState["dataCurrentFibo"] = 2 - turtleState["dataGoalRows"] = 0 - turtleState["dataGoalPathProgress"] = 0 - turtleState["dataCurrentRow"] = 0 - turtleState["dataCurrentPathProgress"] = 0 - turtleState["posX"] = 0 - turtleState["posY"] = 0 - turtleState["posZ"] = 0 - turtleState["rotation"] = 0 --towards south (pos Z) - turtleState["startX"] = 0 - turtleState["startY"] = 0 - turtleState["startZ"] = 0 + state = {} + state["dataCurrentFibo"] = 2 + state["dataGoalRows"] = 0 + state["dataGoalPathProgress"] = 0 + state["dataCurrentRow"] = 0 + state["dataCurrentPathProgress"] = 0 + state["posX"] = 0 + state["posY"] = 0 + state["posZ"] = 0 + state["rotation"] = 0 --towards south (pos Z) + state["startX"] = 0 + state["startY"] = 0 + state["startZ"] = 0 - basic.writeToFile("brulijam/files/state-t-fiboMiner.txt", textutils.serialize(turtleState)) + basic.writeToFile("brulijam/files/state-t-fiboMiner.txt", textutils.serialize(state)) else - turtleState = basic.readFileAll("brulijam/files/state-t-fiboMiner.txt") - turtleState = textutils.unserialize(turtleState) + state = basic.readFileAll("brulijam/files/state-t-fiboMiner.txt") + state = textutils.unserialize(state) end - return turtleState + return state end local function savePos(prefix) - --swap modem with Pickaxe - --by convention the chunkloader is always left, so that Tools are right - for i=1, 16 do - turtle.select(i) - itemDetail = turtle.getItemDetail() - - if itemDetail ~= nil then - if itemDetail.name == "computercraft:wireless_modem_advanced" then - turtle.equipRight() - posZ, posY, posX = gps.locate() - sleep(1) - if prefix == "Chest placed at " then - posY = posY + 1 - end - basic.appendToFileNl("/brulijam/files/chests-turtle-miner-fibo.txt", prefix .. posX .. ", " .. posY .. ", " .. posZ) - networking.sendLog("all", "/brulijam/logs/chests-to-collect.txt", prefix .. posX .. ", " .. posY .. ", " .. posZ) - turtle.equipRight() - end - end - end + --save position to file and ntfy + basic.appendToFileNl("/brulijam/files/chests-turtle-miner-fibo.txt", prefix .. state["x"] .. ", " .. state["y"]+1 .. ", " .. state["z"]) + basic.ntfy("[" .. os.getComputerLabel() .. "](Mining) " .. prefix .. state["x"] .. ", " .. state["y"]+1 .. ", " .. state["z"]) end local function inventoryRework() @@ -136,9 +119,11 @@ local function inventoryRework() --store items away if not spaceAvailable and chestAvailable then - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"]) basic.secureDigUp() - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"]) basic.secureDigUp() turtle.select(chestSlot) turtle.placeUp() @@ -153,8 +138,10 @@ local function inventoryRework() end end end - turtle.down() - turtle.down() + --turtle.down() + state["y"] = tutel.down(state["y"]) + --turtle.down() + state["y"] = tutel.down(state["y"]) end if not spaceAvailable and not chestAvailable then @@ -177,30 +164,37 @@ end local function recursiveOreMining() for i=0, 3 do - turtle.turnLeft() + --turtle.turnLeft() + state["r"] = tutel.left(state["r"]) blockFound, blockData = turtle.inspect() if isOre(blockData) then tutel.secureDig() - turtle.forward() + --turtle.forward() + state["x"], state["y"], state["z"], state["r"] = tutel.forward(state["x"],state["y"],state["z"],state["r"]) recursiveOreMining() - turtle.back() + --turtle.back() + state["x"], state["y"], state["z"], state["r"] = tutel.bac(state["x"],state["y"],state["z"],state["r"]) end end blockFound, blockData = turtle.inspectUp() if isOre(blockData) then tutel.secureDigUp() - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"])state["y"] = tutel.forward(state["y"]) recursiveOreMining() - turtle.down() + --turtle.down() + state["y"] = tutel.down(state["y"]) end blockFound, blockData = turtle.inspectDown() if isOre(blockData) then tutel.secureDigDown() - turtle.down() + --turtle.down() + state["y"] = tutel.down(state["y"]) recursiveOreMining() - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"]) end end @@ -210,7 +204,8 @@ local function mineRow() print("row: " .. state["dataCurrentRow"]+1 .. "/" .. state["dataGoalRows"] .. ", pathProgress: " .. state["dataCurrentPathProgress"]+1 .. "/" .. state["dataGoalPathProgress"]) tutel.secureDig() - turtle.forward() + --turtle.forward() + state["x"], state["y"], state["z"], state["r"] = tutel.forward(state["x"],state["y"],state["z"],state["r"]) tutel.secureDigUp() tutel.secureDigDown() @@ -218,13 +213,17 @@ local function mineRow() --inventoryRework() --check current mining step for ore - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"]) recursiveOreMining() - turtle.down() + --turtle.down() + state["y"] = tutel.down(state["y"]) recursiveOreMining() - turtle.down() + --turtle.down() + state["y"] = tutel.down(state["y"]) recursiveOreMining() - turtle.up() + --turtle.up() + state["y"] = tutel.up(state["y"]) inventoryRework() --clearInventory() @@ -250,22 +249,28 @@ local function mineChunk() --turn back and return to start of row if not last row if i