Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local canstart = true
- print("please enter the current hight")
- io.write("Y cord: ")
- local ycord = io.read()
- ycord = tonumber(ycord)
- if ycord > 319 then
- canstart = false
- print("fuck you")
- end
- print("please enter the desired depth")
- io.write("Y depth: ")
- local ydepth = io.read()
- ydepth = tonumber(ydepth)
- if ydepth < -64 then
- canstart = false
- print("fuck you")
- end
- print("Do you with for the turtle to come back?")
- io.write("Y/N: ")
- local ComeBack = io.read()
- ComeBack = string.lower(ComeBack)
- local original_y
- if string.match(ComeBack,"y") then
- ComeBack = true
- original_y = ycord
- else
- ComeBack = false
- end
- local notblocks = {"torch","sand","gravel"}
- local function moveAndDigForwards()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- local function DigForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- local function findBlockToPlace()
- for i=1,16 do
- local slot = turtle.getItemDetail(i)
- if slot ~= nil then
- turtle.select(i)
- local blockfound = true
- for key,value in pairs(notblocks) do
- if string.find(slot.name,value) ~= nil then
- print("slot " , i , " is not a sutible")
- blockfound = false
- end
- end
- if blockfound then
- print("i found blocks to place")
- return i
- end
- end
- end
- print("i didnt find a block to place")
- return false
- end
- local BlockToPlaceSlot = findBlockToPlace()
- local function digdown()
- if not turtle.down() then
- turtle.digDown()
- turtle.down()
- end
- if (not turtle.detectDown()) and (BlockToPlaceSlot ~= false) then
- turtle.select(BlockToPlaceSlot)
- if not turtle.placeDown() then
- BlockToPlaceSlot = findBlockToPlace()
- if turtle.placeDown() then
- print("just placed a block underneeth me")
- else
- os.exit()
- end
- end
- end
- ycord = ycord - 1
- end
- local function findTorchSlot()
- for i = 1,16 do
- local slot = turtle.getItemDetail(i)
- if (slot ~= nil) and (slot.name == "minecraft:torch") then
- return i
- end
- end
- return false
- end
- local torchSlot = findTorchSlot()
- local function placeTorch()
- torchSlot = findTorchSlot()
- if ycord % 10 == 0 and torchSlot ~= false then
- turtle.select(torchSlot)
- turtle.up()
- turtle.placeUp()
- turtle.down()
- end
- end
- local function MineLayer()
- placeTorch()
- digdown()
- moveAndDigForwards()
- moveAndDigForwards()
- DigForward()
- turtle.back()
- end
- local function mainrun()
- print("digging to depth ", ydepth)
- while ycord ~= ydepth do
- print("my depth is ", ycord)
- MineLayer()
- end
- end
- if canstart then
- mainrun()
- else
- turtle.select(BlockToPlaceSlot)
- turtle.place()
- end
- if ComeBack then
- turtle.turnLeft()
- turtle.turnLeft() --turtle turns around
- while ycord ~= original_y do
- turtle.forward()
- if not turtle.detect() then
- BlockToPlaceSlot = findBlockToPlace()
- if BlockToPlaceSlot ~= false then
- turtle.select(BlockToPlaceSlot)
- turtle.place()
- end
- end
- turtle.up()
- ycord = ycord + 1
- end
- end
Add Comment
Please, Sign In to add comment