.
This commit is contained in:
parent
35e220a14f
commit
908a33431b
@ -55,51 +55,34 @@ end
|
|||||||
|
|
||||||
local function getState()
|
local function getState()
|
||||||
if not fs.exists "brulijam/files/state-t-fiboMiner.txt" then
|
if not fs.exists "brulijam/files/state-t-fiboMiner.txt" then
|
||||||
turtleState = {}
|
state = {}
|
||||||
turtleState["dataCurrentFibo"] = 2
|
state["dataCurrentFibo"] = 2
|
||||||
turtleState["dataGoalRows"] = 0
|
state["dataGoalRows"] = 0
|
||||||
turtleState["dataGoalPathProgress"] = 0
|
state["dataGoalPathProgress"] = 0
|
||||||
turtleState["dataCurrentRow"] = 0
|
state["dataCurrentRow"] = 0
|
||||||
turtleState["dataCurrentPathProgress"] = 0
|
state["dataCurrentPathProgress"] = 0
|
||||||
turtleState["posX"] = 0
|
state["posX"] = 0
|
||||||
turtleState["posY"] = 0
|
state["posY"] = 0
|
||||||
turtleState["posZ"] = 0
|
state["posZ"] = 0
|
||||||
turtleState["rotation"] = 0 --towards south (pos Z)
|
state["rotation"] = 0 --towards south (pos Z)
|
||||||
turtleState["startX"] = 0
|
state["startX"] = 0
|
||||||
turtleState["startY"] = 0
|
state["startY"] = 0
|
||||||
turtleState["startZ"] = 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
|
else
|
||||||
turtleState = basic.readFileAll("brulijam/files/state-t-fiboMiner.txt")
|
state = basic.readFileAll("brulijam/files/state-t-fiboMiner.txt")
|
||||||
turtleState = textutils.unserialize(turtleState)
|
state = textutils.unserialize(state)
|
||||||
end
|
end
|
||||||
return turtleState
|
return state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function savePos(prefix)
|
local function savePos(prefix)
|
||||||
--swap modem with Pickaxe
|
--save position to file and ntfy
|
||||||
--by convention the chunkloader is always left, so that Tools are right
|
basic.appendToFileNl("/brulijam/files/chests-turtle-miner-fibo.txt", prefix .. state["x"] .. ", " .. state["y"]+1 .. ", " .. state["z"])
|
||||||
for i=1, 16 do
|
basic.ntfy("[" .. os.getComputerLabel() .. "](Mining) " .. prefix .. state["x"] .. ", " .. state["y"]+1 .. ", " .. state["z"])
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function inventoryRework()
|
local function inventoryRework()
|
||||||
@ -136,9 +119,11 @@ local function inventoryRework()
|
|||||||
|
|
||||||
--store items away
|
--store items away
|
||||||
if not spaceAvailable and chestAvailable then
|
if not spaceAvailable and chestAvailable then
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])
|
||||||
basic.secureDigUp()
|
basic.secureDigUp()
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])
|
||||||
basic.secureDigUp()
|
basic.secureDigUp()
|
||||||
turtle.select(chestSlot)
|
turtle.select(chestSlot)
|
||||||
turtle.placeUp()
|
turtle.placeUp()
|
||||||
@ -153,8 +138,10 @@ local function inventoryRework()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
turtle.down()
|
--turtle.down()
|
||||||
turtle.down()
|
state["y"] = tutel.down(state["y"])
|
||||||
|
--turtle.down()
|
||||||
|
state["y"] = tutel.down(state["y"])
|
||||||
end
|
end
|
||||||
|
|
||||||
if not spaceAvailable and not chestAvailable then
|
if not spaceAvailable and not chestAvailable then
|
||||||
@ -177,30 +164,37 @@ end
|
|||||||
|
|
||||||
local function recursiveOreMining()
|
local function recursiveOreMining()
|
||||||
for i=0, 3 do
|
for i=0, 3 do
|
||||||
turtle.turnLeft()
|
--turtle.turnLeft()
|
||||||
|
state["r"] = tutel.left(state["r"])
|
||||||
blockFound, blockData = turtle.inspect()
|
blockFound, blockData = turtle.inspect()
|
||||||
if isOre(blockData) then
|
if isOre(blockData) then
|
||||||
tutel.secureDig()
|
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()
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
blockFound, blockData = turtle.inspectUp()
|
blockFound, blockData = turtle.inspectUp()
|
||||||
if isOre(blockData) then
|
if isOre(blockData) then
|
||||||
tutel.secureDigUp()
|
tutel.secureDigUp()
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])state["y"] = tutel.forward(state["y"])
|
||||||
recursiveOreMining()
|
recursiveOreMining()
|
||||||
turtle.down()
|
--turtle.down()
|
||||||
|
state["y"] = tutel.down(state["y"])
|
||||||
end
|
end
|
||||||
|
|
||||||
blockFound, blockData = turtle.inspectDown()
|
blockFound, blockData = turtle.inspectDown()
|
||||||
if isOre(blockData) then
|
if isOre(blockData) then
|
||||||
tutel.secureDigDown()
|
tutel.secureDigDown()
|
||||||
turtle.down()
|
--turtle.down()
|
||||||
|
state["y"] = tutel.down(state["y"])
|
||||||
recursiveOreMining()
|
recursiveOreMining()
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -210,7 +204,8 @@ local function mineRow()
|
|||||||
print("row: " .. state["dataCurrentRow"]+1 .. "/" .. state["dataGoalRows"] .. ", pathProgress: " .. state["dataCurrentPathProgress"]+1 .. "/" .. state["dataGoalPathProgress"])
|
print("row: " .. state["dataCurrentRow"]+1 .. "/" .. state["dataGoalRows"] .. ", pathProgress: " .. state["dataCurrentPathProgress"]+1 .. "/" .. state["dataGoalPathProgress"])
|
||||||
|
|
||||||
tutel.secureDig()
|
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.secureDigUp()
|
||||||
tutel.secureDigDown()
|
tutel.secureDigDown()
|
||||||
|
|
||||||
@ -218,13 +213,17 @@ local function mineRow()
|
|||||||
--inventoryRework()
|
--inventoryRework()
|
||||||
|
|
||||||
--check current mining step for ore
|
--check current mining step for ore
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])
|
||||||
recursiveOreMining()
|
recursiveOreMining()
|
||||||
turtle.down()
|
--turtle.down()
|
||||||
|
state["y"] = tutel.down(state["y"])
|
||||||
recursiveOreMining()
|
recursiveOreMining()
|
||||||
turtle.down()
|
--turtle.down()
|
||||||
|
state["y"] = tutel.down(state["y"])
|
||||||
recursiveOreMining()
|
recursiveOreMining()
|
||||||
turtle.up()
|
--turtle.up()
|
||||||
|
state["y"] = tutel.up(state["y"])
|
||||||
|
|
||||||
inventoryRework()
|
inventoryRework()
|
||||||
--clearInventory()
|
--clearInventory()
|
||||||
@ -250,22 +249,28 @@ local function mineChunk()
|
|||||||
|
|
||||||
--turn back and return to start of row if not last row
|
--turn back and return to start of row if not last row
|
||||||
if i<state["dataGoalRows"]-1 then
|
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
|
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
|
end
|
||||||
|
|
||||||
--go to next row
|
--go to next row
|
||||||
turtle.turnLeft()
|
--turtle.turnLeft()
|
||||||
|
state["r"] = tutel.left(state["r"])
|
||||||
for j=0, 2 do
|
for j=0, 2 do
|
||||||
tutel.secureDig()
|
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.secureDigUp()
|
||||||
tutel.secureDigDown()
|
tutel.secureDigDown()
|
||||||
end
|
end
|
||||||
turtle.turnLeft()
|
--turtle.turnLeft()
|
||||||
|
state["r"] = tutel.left(state["r"])
|
||||||
end
|
end
|
||||||
|
|
||||||
state["dataCurrentRow"] = i+1
|
state["dataCurrentRow"] = i+1
|
||||||
@ -283,10 +288,12 @@ local function mineFibo()
|
|||||||
mineChunk()
|
mineChunk()
|
||||||
|
|
||||||
--go to next chunk
|
--go to next chunk
|
||||||
turtle.turnRight()
|
--turtle.turnRight()
|
||||||
|
state["r"] = tutel.right(state["r"])
|
||||||
for j=1, 2 do
|
for j=1, 2 do
|
||||||
tutel.secureDig()
|
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.secureDigUp()
|
||||||
tutel.secureDigDown()
|
tutel.secureDigDown()
|
||||||
end
|
end
|
||||||
@ -312,13 +319,13 @@ else
|
|||||||
write("r (S=0,W=1,N=2,E=3):")
|
write("r (S=0,W=1,N=2,E=3):")
|
||||||
startR = read()
|
startR = read()
|
||||||
|
|
||||||
turtleState["x"] = startX
|
state["x"] = startX
|
||||||
turtleState["y"] = startY
|
state["y"] = startY
|
||||||
turtleState["z"] = startZ
|
state["z"] = startZ
|
||||||
turtleState["r"] = startR
|
state["r"] = startR
|
||||||
|
|
||||||
turtleState["startX"] = startX
|
state["startX"] = startX
|
||||||
turtleState["startY"] = startY
|
state["startY"] = startY
|
||||||
turtleState["startZ"] = startZ
|
state["startZ"] = startZ
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user