Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function find(itemName)
- print("Searching for",itemName)
- for curSlot = 1,16 do
- if turtle.getItemCount(curSlot) >= 1 then
- local data = turtle.getItemDetail(curSlot)
- if data.name == itemName then
- print("Found",itemName,"in slot",curSlot)
- return curSlot
- end
- end
- end
- print("Could not find",itemName)
- return false
- end
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: miner <distance>" )
- return
- end
- local maxDist = tonumber( tArgs[1] )
- if maxDist < 1 then
- print( "Distance must be positive" )
- return
- end
- local function digAround()
- while turtle.detectUp() do
- turtle.digUp()
- end
- if turtle.detectDown() then
- local success, data = turtle.inspectDown()
- if success then
- if not (data.name == "minecraft:cobblestone") and not (data.name == "minecraft:stone") and not (data.name == "minecraft:sand") and not (data.name == "minecraft:dirt") and not (data.name == "minecraft:gravel") and not (data.name == "chisel:marble2") and not (data.name == "chisel:limestone2") then
- turtle.digDown()
- end
- end
- end
- if find("minecraft:cobblestone") then
- turtle.select(find("minecraft:cobblestone"))
- turtle.placeDown()
- elseif find("minecraft:stone") then
- turtle.select(find("minecraft:stone"))
- turtle.placeDown()
- end
- end
- local function checkFuel(level)
- if (turtle.getFuelLevel() <= level) and (find("minecraft:coal")) then
- turtle.select(find("minecraft:coal"))
- turtle.refuel(1)
- end
- end
- for curDist=0,maxDist do
- checkFuel(10)
- digAround()
- turtle.turnLeft()
- while not turtle.forward() do
- turtle.dig()
- end
- digAround()
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- while not turtle.forward() do
- turtle.dig()
- end
- digAround()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- if (curDist % 7 == 0) and (find("minecraft:torch")) then
- turtle.select(find("minecraft:torch"))
- turtle.place()
- end
- turtle.turnRight()
- if curDist ~= maxDist then
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for curDist=0,maxDist do
- local success, data = turtle.inspect()
- if success then
- if data.name ~= "minecraft:chest" then
- while not turtle.forward() do
- turtle.dig()
- end
- end
- else
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- for curSlot = 1,16 do
- turtle.select(curSlot)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment