Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs ={...}
- local torchLoc = 1
- local torchDist = 6
- function findTorchLoc()
- torchLoc = 0
- for i = 1,16 do
- local data = turtle.getItemDetail(i)
- -- print("i",i)
- if turtle.getItemCount(i) > 0 then
- if data.name == "minecraft:torch" then
- torchLoc = i
- print("torchLoc: ", torchLoc)
- end
- end
- end
- end
- function placeTorch()
- findTorchLoc()
- if torchLoc > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(torchLoc)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function checkFuel()
- local slot = 1
- while turtle.getFuelLevel() < 80 do
- print("Fuel Level:", turtle.getFuelLevel())
- for i=1,16 do
- turtle.select(i)
- turtle.refuel(20)
- end
- print("Fuel Level:", turtle.getFuelLevel())
- end
- end
- function findSlot(ItemName)
- for i =1,16 do
- if turtle.getItemCount(i) > 0 then
- -- print(turtle.getItemCount(i))
- local data2 = turtle.getItemDetail(i)
- -- print(data2.name)
- -- print(ItemName)
- if ItemName == data2.name then
- return
- end
- end
- end
- end
- function dig(direction)
- if direction == "up" then
- local success, data = turtle.inspectUp()
- turtle.digUp()
- elseif direction == "down" then
- local success, data = turtle.inspectDonw()
- while data.name ~= "minecraft:gravel" do
- turtle.digDown()
- end
- findSlot(data.name)
- turtle.digDown()
- else
- local succ, data = turtle.inspect()
- while data.name == "minecraft:gravel" do
- turtle.dig()
- succ, data = turtle.inspect()
- print(data.name)
- end
- findSlot(data.name)
- turtle.dig()
- end
- end
- function digForward()
- dig()
- turtle.forward()
- dig("up")
- turtle.turnLeft()
- dig()
- turtle.up()
- dig()
- turtle.turnLeft()
- turtle.turnLeft()
- dig()
- turtle.down()
- dig()
- turtle.turnLeft()
- end
- distance = 1
- local startFace = 0
- distance = tArgs[1]
- if tArgs[2] == "right" then
- print ("Digging forward and to the right")
- startFace = 2
- elseif tArgs[2] == 'left' then
- print ("Digging forward and to the left")
- startFace = 1
- end
- findTorchLoc()
- local continue = true
- while continue do
- local currentDist = 1
- for i = 1, distance do
- checkFuel()
- digForward()
- currentDist = currentDist + 1
- if math.fmod(currentDist, torchDist) == 0 then
- placeTorch()
- end
- end
- if startFace == 1 then
- turtle.turnLeft()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- startFace = 2
- elseif startFace == 2 then
- turtle.turnRight()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- startFace = 1
- elseif startFace == 0 then
- continue = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement