Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
Advertisement
Add Comment
Please, Sign In to add comment