Posted 14 November 2012 - 02:12 PM
This is a branch miner program… to use it add it to your programs in a miner turtle as miner.
Then start it using these arguments:
miner [total branches] [blocks between branches] [length of branch]
Pastebin: http://pastebin.com/hC4g99bj
Then start it using these arguments:
miner [total branches] [blocks between branches] [length of branch]
Pastebin: http://pastebin.com/hC4g99bj
local prgm_args = {...};
if(prgm_args[1] == 'usage' or prgm_args[1] == '?' or prgm_args[1] == 'help')then
print("miner <branches> <blocks between branches> <branch length>");
return true;
end
local branches = tonumber(prgm_args[1]) or 5;
local branch_interval = (prgm_args[2]~=nil and tonumber(prgm_args[2])+1) or 4;
local branch_length = tonumber(prgm_args[3]) or 10;
local trunk_length = branches*branch_interval;
local cTrunk
local cBranch = 0;
function dig(length)
local cLength = 0;
local bDetect, bMoved;
while(cLength < length)do
repeat turtle.dig(); os.sleep(0.1); bDetect = turtle.detect(); until bDetect == false;
bMoved = turtle.forward();
if(bMoved)then
cLength = cLength + 1;
turtle.digUp();
turtle.digDown();
end
end
while(cLength~=0)do
bMoved = turtle.back();
if(bMoved)then
cLength = cLength - 1;
end
end
end
function digTrunk()
local cLength = 0;
local bDetect, bMoved;
while(cLength < trunk_length)do
repeat turtle.dig(); os.sleep(0.1); bDetect = turtle.detect(); until bDetect == false;
bMoved = turtle.forward();
if(bMoved)then
cLength = cLength + 1;
turtle.digUp();
turtle.digDown();
if(cLength%branch_interval==0)then
turtle.turnRight();
dig(branch_length);
turtle.turnLeft();
turtle.turnLeft();
dig(branch_length);
turtle.turnRight();
end
end
end
while(cLength~=0)do
bMoved = turtle.back();
if(bMoved)then
cLength = cLength - 1;
end
end
end
digTrunk();