Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function findNeighbouringBlock(blockName)
- for i=1, 4 do
- local hasBlock, block = turtle.inspect();
- if block and block.name == blockName then
- return true;
- end
- turtle.turnRight();
- end
- return false;
- end
- local function getItemCount(itemName)
- local total = 0;
- for i=1, 16 do
- local itemDetail = turtle.getItemDetail(i);
- if itemDetail and itemDetail.name == itemName then
- total = total + turtle.getItemCount(i);
- end
- end
- return total;
- end
- local function mineCobble(amount)
- while getItemCount("minecraft:cobblestone") < amount do
- if turtle.detect() then
- turtle.dig();
- end
- end
- end
- local function depositCobble()
- while getItemCount("minecraft:cobblestone") > 0 do
- for i=1, 16 do
- turtle.drop();
- end
- end
- end
- local function main()
- local foundCobble = findNeighbouringBlock("minecraft:cobblestone");
- if not foundCobble then
- print("Couldn't find the cobble gen.");
- return;
- end
- local foundChest, _ = findNeighbouringBlock("minecraft:chest");
- if not foundChest then
- print("Couldn't find chest.");
- return;
- end
- turtle.turnLeft();
- turtle.turnLeft();
- local running = true;
- while running do
- mineCobble(64);
- turtle.turnRight();
- turtle.turnRight();
- depositCobble();
- turtle.turnRight();
- turtle.turnRight();
- end
- end
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement