Posted 11 August 2015 - 06:20 PM
TL:DR: I want to add a function that dives the turtle down until it hits a non-air non-water block to the default excavate script. This would allow my turtle to skip the large sections of air and water between starting location and surface level. If you are curious I have a sky base over a deep ocean.
Part 1:
I may be tackling this in entirely the wrong direction, if so please feel free to redirect my pursuits at even the most fundamental levels.
I am going about it with the turtle.detectDown() command.
turtle.detectDown() reports back a false for air blocks and water blocks and true for solid blocks
I guess i'm having trrouble writing my while loops to accomdate the false report.
"while turtle.detectDown(1) do" does not seem to trigger with a false report like "while turtle.detectDown() do" does with a true report
The test I setup was
local function rushDown()
while turtle.detectDown(1) do
turtle.down()
end
while turtle.detectDown() do
write.term("Reached Bottom")
end
end
But my issues with turning a false report from detectDown into a do function in a while loop is really stalling me.
Part 2
I would then like to inject it into the excavate script.. I don't know a good way to get it dumped into pastebin or this forum to do an in-line reference. I copied the Excavate script to the root directory to edit it. I'm hoping that for the purpose of the second part of this question that you, as the viewer and possibly answerer, would have access to this script independently for review and reference. Apologies ahead of time.
It appears to start mining with use of the "Return to Mining" function triggered by a change of local variables in the "Restocking" function. It does not seem ot have a true "start mining" section and simply starts its loop with checking for full inventory or low fuel, returning to base, restocking, and returning to mining. When the loop is unstated those coordinate variables are set to ~ ~ ~, changed dynamically by progression of the loop, which allows use of the "Return to Mining" section to start the first mined block.
so its got a "local xPos,zPos = 0,0" and "local xDir,zDir = 0,1" setup initially
the function returnSupplies() sets "local x,y,z,xd,zd = xPos,depth,zPos,xD with a goto( 0,0,0,0,-1)
there is no true "Resuming mining" function, just a print( function with a goto( x,y,z,xd,zd) call from the previously set variables in the "returnSupplies" function
So if I get my rushDown function functional I should be able to have it set the local variables for x,y,z,xd,zd based on the xPos,depth,zPos, and xD variables and do the goTo( 0,0,0,0,-1) just as the returnSupplies function does it (removing those steps from the returnSupplies function)
I think it would be safe to inject the rushDown function directly above the print( "Resuming mining…") and goTo( x,y,z,xd,zd) commands
Again, if I am doing this the wrong way, or there is an existing user-created excavation script you would recommend adapting with my rushDown function for better results, please don't hesitate to make any and all recommendations.
Thanks in advanced
-Chris
Part 1:
I may be tackling this in entirely the wrong direction, if so please feel free to redirect my pursuits at even the most fundamental levels.
I am going about it with the turtle.detectDown() command.
turtle.detectDown() reports back a false for air blocks and water blocks and true for solid blocks
I guess i'm having trrouble writing my while loops to accomdate the false report.
"while turtle.detectDown(1) do" does not seem to trigger with a false report like "while turtle.detectDown() do" does with a true report
The test I setup was
local function rushDown()
while turtle.detectDown(1) do
turtle.down()
end
while turtle.detectDown() do
write.term("Reached Bottom")
end
end
But my issues with turning a false report from detectDown into a do function in a while loop is really stalling me.
Part 2
I would then like to inject it into the excavate script.. I don't know a good way to get it dumped into pastebin or this forum to do an in-line reference. I copied the Excavate script to the root directory to edit it. I'm hoping that for the purpose of the second part of this question that you, as the viewer and possibly answerer, would have access to this script independently for review and reference. Apologies ahead of time.
It appears to start mining with use of the "Return to Mining" function triggered by a change of local variables in the "Restocking" function. It does not seem ot have a true "start mining" section and simply starts its loop with checking for full inventory or low fuel, returning to base, restocking, and returning to mining. When the loop is unstated those coordinate variables are set to ~ ~ ~, changed dynamically by progression of the loop, which allows use of the "Return to Mining" section to start the first mined block.
so its got a "local xPos,zPos = 0,0" and "local xDir,zDir = 0,1" setup initially
the function returnSupplies() sets "local x,y,z,xd,zd = xPos,depth,zPos,xD with a goto( 0,0,0,0,-1)
there is no true "Resuming mining" function, just a print( function with a goto( x,y,z,xd,zd) call from the previously set variables in the "returnSupplies" function
So if I get my rushDown function functional I should be able to have it set the local variables for x,y,z,xd,zd based on the xPos,depth,zPos, and xD variables and do the goTo( 0,0,0,0,-1) just as the returnSupplies function does it (removing those steps from the returnSupplies function)
I think it would be safe to inject the rushDown function directly above the print( "Resuming mining…") and goTo( x,y,z,xd,zd) commands
Again, if I am doing this the wrong way, or there is an existing user-created excavation script you would recommend adapting with my rushDown function for better results, please don't hesitate to make any and all recommendations.
Thanks in advanced
-Chris