Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local size = tonumber( tArgs[1] )
- local offset = 0
- if tArgs[2] then
- offset = tonumber( tArgs[2])
- end
- local side = 0
- if tArgs[3] then
- local pari3 = tonumber( tArgs[3])
- if pari3 == 1 then
- side = 1
- elseif pari3 == 2 then
- side = 2
- else
- side = 0
- end
- end
- if size < 1 then
- print( "Range of the Tunnel must be positive!" )
- return
- end
- local function slotsLeft()
- local slotsleft=16
- for slot = 1, 16, 1 do
- if turtle.getItemCount(slot) > 0 then
- slotsleft = slotsleft-1
- end
- end
- return slotsleft
- end
- local function dropItems()
- for slot = 1, 16, 1 do
- turtle.select(slot)
- turtle.dropDown()
- end
- end
- local function searchForCoal()
- for slot = 1, 16, 1 do
- local data = turtle.getItemDetail(slot)
- if data then
- if data.name == 'minecraft:coal' then
- return slot
- end
- end
- end
- end
- if searchForCoal() then
- print(searchForCoal())
- end
- local blocksMoved=0
- local gotbackbcofInv = false
- local gotbackbcofFuel= false
- local gotbackbcofSize= false
- turtle.refuel()
- print("Refueled!")
- local fuelLevel=turtle.getFuelLevel()
- print("FuelLevel: "..fuelLevel)
- if turtle.getFuelLevel() < size+offset then
- print("Insufficient FuelLevel!")
- return
- end
- local ofs = offset + 20
- while true do
- while true do
- if offset > 0 then
- for forwardset = 1, offset, 1 do
- if turtle.getFuelLevel() < blocksMoved+ofs then
- if searchForCoal() then
- turtle.select(searchForCoal())
- turtle.refuel()
- else
- gotbackbcofFuel = true
- print("fuel3!!!")
- break
- end
- end
- turtle.forward()
- end
- -- If Side = 1 ... right side
- if side==1 then
- turtle.turnRight()
- -- If Side = 2 ... left side (default)
- else
- turtle.turnLeft()
- end
- end
- while true do
- if slotsLeft() < 1 then
- print(slotsLeft())
- gotbackbcofInv = true
- break
- end
- if turtle.detectUp() then
- turtle.digUp()
- elseif turtle.detect() then
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- blocksMoved=blocksMoved+1
- if blocksMoved > size then
- gotbackbcofSize = true
- break
- end
- if turtle.getFuelLevel() < blocksMoved+ofs then
- if searchForCoal() then
- turtle.select(searchForCoal())
- turtle.refuel()
- else
- gotbackbcofFuel = true
- print("fuel3!!!")
- break
- end
- end
- else
- turtle.forward()
- blocksMoved=blocksMoved+1
- if blocksMoved > size then
- gotbackbcofSize = true
- break
- end
- if turtle.getFuelLevel() < blocksMoved+ofs then
- if searchForCoal() then
- turtle.select(searchForCoal())
- turtle.refuel()
- else
- gotbackbcofFuel = true
- print("fuel3!!!")
- break
- end
- end
- end
- print(turtle.getFuelLevel())
- end
- -- Initiating the going back
- turtle.turnLeft()
- turtle.turnLeft()
- for moves = 1, blocksMoved, 1 do
- turtle.forward()
- end
- if offset > 0 then
- if side==1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- for forwardset = 1, offset, 1 do
- turtle.forward()
- end
- dropItems()
- if gotbackbcofSize then
- break
- end
- if gotbackbcofInv then
- break
- end
- if gotbackbcofFuel then
- break
- end
- end
- if gotbackbcofSize then
- break
- end
- if gotbackbcofFuel then
- break
- else
- turtle.turnLeft()
- turtle.turnLeft()
- blocksMoved = 0
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- print("Mining finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement