Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- API
- looseBlocks = {"minecraft:gravel","minecraft:sand"};
- distance = 0;
- blocksMined = 0;
- function clc(x,y,bc,tc)
- x = x or 1;
- y = y or 1;
- bc = bc or colors.black;
- tc = tc or colors.white;
- term.setCursorPos(x,y);
- term.setBackgroundColor(bc);
- term.setTextColor(tc);
- term.clear();
- end
- function attack()
- local success = true;
- while (success) do
- success = turtle.attack();
- end
- end
- function attackUp()
- local success = true;
- while (success) do
- success = turtle.attackUp();
- end
- end
- function attackDown()
- local success = true;
- while (success) do
- success = turtle.attackDown();
- end
- end
- function dig()
- if turtle.dig() then
- blocksMined = blocksMined + 1;
- return blocksMined;
- end
- end
- function digUp()
- if turtle.digUp() then
- blocksMined = blocksMined + 1;
- return blocksMined;
- end
- end
- function digDown()
- if turtle.digDown() then
- blocksMined = blocksMined + 1;
- return blocksMined;
- end
- end
- function fw()
- local success = false;
- while (success == false) do
- success = turtle.forward();
- end
- end
- function b()
- local success = false;
- while (success == false) do
- success = turtle.back();
- end
- end
- function u()
- local success = false;
- while (success == false) do
- success = turtle.up();
- end
- end
- function d()
- local success = false;
- while (success == false) do
- success = turtle.down();
- end
- end
- function isLoose()
- local found = false;
- for i=1, #looseBlocks do
- local scs, block = turtle.inspect();
- if (block.name == looseBlocks[i]) then
- found = true;
- end
- end
- return found;
- end
- function isLooseUp()
- local found = false;
- for i=1, #looseBlocks do
- local scs, block = turtle.inspectUp();
- if (block.name == looseBlocks[i]) then
- found = true;
- end
- end
- return found;
- end
- function isLooseDown()
- local found = false;
- for i=1, #looseBlocks do
- local scs, block = turtle.inspectDown();
- if (block.name == looseBlocks[i]) then
- found = true;
- end
- end
- return found;
- end
- function fwd(length)
- for i=1, length do
- dig();
- turtle.attack();
- fw(); distance = distance + 1;
- end
- end
- function inventoryFull()
- if (0 < turtle.getItemCount(16)) then
- return true;
- else
- return false;
- end
- end
- function place(lastSlot)
- lastSlot = lastSlot or 16;
- for i=1,lastSlot do
- local count = turtle.getItemCount(i);
- if (0 < count) then turtle.place(); break; end
- end
- end
- function placeUp(lastSlot)
- lastSlot = lastSlot or 16;
- for i=1,lastSlot do
- local count = turtle.getItemCount(i);
- if (0 < count) then turtle.placeUp(); break; end
- end
- end
- function placeDown(lastSlot)
- lastSlot = lastSlot or 16;
- for i=1,lastSlot do
- local count = turtle.getItemCount(i);
- if (0 < count) then turtle.placeDown(); break; end
- end
- end
- function turn(invert)
- invert = invert or false;
- if invert then turtle.turnRight(); turtle.turnRight();
- else turtle.turnLeft(); turtle.turnLeft(); end
- end
- function digA(ignoreUp, ignoreDown)
- ignoreUp = ignoreUp or false;
- ignoreDown = ignoreDown or false;
- dig(); sleep(sleepTime);
- attack();
- while ( isLoose() ) do
- dig();
- sleep(sleepTime);
- end
- fw(); distance = distance + 1;
- if (ignoreUp==false) then
- digUp(); sleep(sleepTime);
- attackUp();
- while ( isLooseUp() ) do
- digUp();
- sleep(sleepTime);
- end
- end
- if (ignoreDown==false) then
- digDown(); sleep(sleepTime);
- attackDown();
- if ( isLooseDown() ) then
- for n=1, 4 do
- while ( isLoose() ) do
- dig();
- sleep(sleepTime);
- end
- turtle.turnLeft();
- end
- end
- end
- return inventoryFull();
- end
Advertisement
Add Comment
Please, Sign In to add comment