Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- -- Config to determine what the turtle should mine
- local config = {
- ["diamond"] = true,
- ["iron ore"] = true,
- ["misc"] = false,
- }
- local minFuelLevel = 200
- local torchSlot = 1
- local fuelSlot = 2
- local chestSlot = 3
- local function initialize()
- print("Starting turtle...")
- print("Torches set to slot "..torchSlot)
- print("Fuel set to slot "..fuelSlot)
- end
- local function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- local function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- local function dig()
- while turtle.detect() do
- turtle.dig()
- end
- end
- local function forward()
- while not turtle.forward() do
- dig()
- end
- end
- local function up()
- while not turtle.up() do
- digUp()
- end
- end
- local function down()
- while not turtle.down() do
- digDown()
- end
- end
- local function aboutFace()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function checkFuelLevel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < minFuelLevel then
- turtle.select(fuelSlot)
- turtle.refuel(1)
- print("Refuelling... fuel level is now "..turtle.getFuelLevel())
- end
- end
- local function placeChest()
- -- Place a chest behind the turtle
- turtle.select(chestSlot)
- dig()
- turtle.place()
- for i = 4, 16 do
- turtle.drop()
- end
- end
- local function mineAboutMine()
- dig()
- turtle.turnLeft()
- turtle.turnLeft()
- dig()
- end
- local function doStripMine()
- local stripLength = 3
- checkFuelLevel()
- ------------------------------------
- -- STARTING FROM MIDDLE, GO UP THEN MINE DOWN
- ------------------------------------
- up()
- for i=1, stripLength / 2 do
- checkFuelLevel()
- -- Mine top layer, finish looking right
- turtle.turnLeft()
- dig()
- aboutFace()
- dig()
- if (i % 7) == 0 then
- turtle.select(torchSlot)
- turtle.place()
- end
- -- Mine middle layer, finish looking left
- down()
- dig()
- aboutFace()
- dig()
- -- Mine bottom layer, finish looking right
- down()
- dig()
- aboutFace()
- dig()
- -- Go forwards to start mining the next layer
- turtle.turnLeft()
- forward()
- ------------------------------------
- -- STARTING FROM BOTTOM, MINE UP TO THE TOP
- ------------------------------------
- -- Mine bottom layer, finish looking right
- turtle.turnLeft()
- dig()
- aboutFace()
- dig()
- -- Mine middle layer, finish looking left
- up()
- dig()
- aboutFace()
- dig()
- -- Mine top layer, finish looking forward
- up()
- dig()
- aboutFace()
- dig()
- turtle.turnLeft()
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, stripLength do
- turtle.forward()
- end
- placeChest()
- end
- for i=1, 10 do
- doStripMine()
- turtle.turnLeft()
- for j=1, 6 do
- forward()
- digUp()
- digDown()
- end
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement