.
This commit is contained in:
parent
35e220a14f
commit
908a33431b
@ -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<state["dataGoalRows"]-1 then
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
--turtle.turnLeft()
|
||||
state["r"] = tutel.left(state["r"])
|
||||
--turtle.turnLeft()
|
||||
state["r"] = tutel.left(state["r"])
|
||||
|
||||
for j=1, state["dataGoalPathProgress"]-1 do
|
||||
turtle.forward()
|
||||
--turtle.forward()
|
||||
state["x"], state["y"], state["z"], state["r"] = tutel.forward(state["x"],state["y"],state["z"],state["r"])
|
||||
end
|
||||
|
||||
--go to next row
|
||||
turtle.turnLeft()
|
||||
--turtle.turnLeft()
|
||||
state["r"] = tutel.left(state["r"])
|
||||
for j=0, 2 do
|
||||
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()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
--turtle.turnLeft()
|
||||
state["r"] = tutel.left(state["r"])
|
||||
end
|
||||
|
||||
state["dataCurrentRow"] = i+1
|
||||
@ -283,10 +288,12 @@ local function mineFibo()
|
||||
mineChunk()
|
||||
|
||||
--go to next chunk
|
||||
turtle.turnRight()
|
||||
--turtle.turnRight()
|
||||
state["r"] = tutel.right(state["r"])
|
||||
for j=1, 2 do
|
||||
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()
|
||||
end
|
||||
@ -312,13 +319,13 @@ else
|
||||
write("r (S=0,W=1,N=2,E=3):")
|
||||
startR = read()
|
||||
|
||||
turtleState["x"] = startX
|
||||
turtleState["y"] = startY
|
||||
turtleState["z"] = startZ
|
||||
turtleState["r"] = startR
|
||||
state["x"] = startX
|
||||
state["y"] = startY
|
||||
state["z"] = startZ
|
||||
state["r"] = startR
|
||||
|
||||
turtleState["startX"] = startX
|
||||
turtleState["startY"] = startY
|
||||
turtleState["startZ"] = startZ
|
||||
state["startX"] = startX
|
||||
state["startY"] = startY
|
||||
state["startZ"] = startZ
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user