Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- posX = 0
- curX = 0
- posY = 0
- curY = 0
- posZ = 0
- curZ = 0
- yaw = 0
- curYaw = 0
- local tArgs = {...}
- if #tArgs ~= 4 then
- print( "Usage: quarry <length> <width> <starting Y level> <toBedrock (true|false)>" )
- return
- end
- local len = tonumber( tArgs[1] )
- if len < 1 then
- print( "Quarry dimension must be positive" )
- return
- end
- local wid = tonumber( tArgs[2] )
- if wid < 1 then
- print( "Quarry dimension must be positive" )
- return
- end
- local levY = tonumber( tArgs[3] )
- if levY <= 6 then
- print( "Quarry must start above y level 6" )
- return
- end
- local bedrock = tonumber( tArgs[4] )
- if not bedrock == "true" or not bedrock == "false" then
- print( "You must specify if the quarry goes to bedrock (true|false)" )
- return
- end
- local function refuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" or fuelLevel > 0 then
- return
- end
- local function tryRefuel()
- for n=1,16 do
- count = turtle.getItemCount(n)
- if count > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- if count < 4 then
- goChest()
- empty()
- goPos()
- end
- turtle.select(1)
- return true
- end
- end
- end
- turtle.select(1)
- return false
- end
- if not tryRefuel() then
- print( "Add more fuel to continue." )
- while not tryRefuel() do
- sleep(1)
- end
- print( "Resuming Mining" )
- end
- end
- local function moveUp()
- refuel()
- turtle.up()
- posY = posY + 1
- end
- local function moveDown()
- refuel()
- turtle.down()
- posY = posY + 1
- end
- local function moveForward()
- refuel()
- turtle.forward()
- if yaw == 0 then
- posX = posX + 1
- end
- if yaw == 1 then
- posZ = posZ + 1
- end
- if yaw == 2 then
- posX = posX - 1
- end
- if yaw == 3 then
- posZ = posZ - 1
- end
- end
- local function moveBack()
- refuel()
- turtle.back()
- if yaw == 0 then
- posX = posX - 1
- end
- if yaw == 1 then
- posZ = posZ - 1
- end
- if yaw == 2 then
- posX = posX + 1
- end
- if yaw == 3 then
- posZ = posZ + 1
- end
- end
- local function turnRight()
- refuel()
- turtle.turnRight()
- yaw = yaw + 1
- if yaw == 4 then
- yaw = 0
- end
- end
- local function turnLeft()
- refuel()
- turtle.turnLeft()
- yaw = yaw - 1
- if yaw == -1 then
- yaw = 3
- end
- end
- local function goChest()
- curX = posX
- curY = posY
- curZ = posZ
- curYaw = yaw
- for x = curYaw,0,-1 do
- turnLeft()
- end
- if curY < 0 then
- for x = curY,0,1 do
- moveUp()
- end
- else
- for x = curY,0,-1 do
- moveDown()
- end
- end
- for x = curX,0,-1 do
- moveBack()
- end
- turnRight()
- for x = curZ,0,-1 do
- moveBack()
- end
- turnLeft()
- end
- local function goPos()
- for x = 0,curX,1 do
- moveForward()
- end
- turnRight()
- for x = 0,curZ,1 do
- moveForward()
- end
- turnLeft()
- for x = 0,curY,-1 do
- moveDown()
- end
- for x = 0,curYaw,1 do
- turnRight()
- end
- end
- local function invCheck()
- slotFull = turtle.getItemSpace(15)
- if slotFull == 0 then
- goChest()
- fill = turtle.getItemSpace(16)
- empty()
- goPos()
- end
- end
- local function empty()
- turtle.turnRight()
- turtle.turnRight()
- for s = 1,15,1 do
- turtle.drop()
- end
- turtle.select(16)
- turtle.suck(turtle.getItemSpace(16))
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if bedrock == "false" then
- print( "How deep should the quarry go?" )
- hgt = read()
- else
- hgt = 6
- end
- refuel()
- for actY = 0,levY - hgt,1 do
- for actZ = 0,wid,1 do
- for actX = 0,len - 1,1 do
- turtle.dig()
- moveForward()
- invCheck()
- end
- if actZ % 2 == 0 then
- turnRight()
- turtle.dig()
- moveForward()
- turnRight()
- end
- if actZ % 2 == 1 then
- turnLeft()
- turtle.dig()
- moveForward()
- turnLeft()
- end
- end
- goChest()
- empty()
- for y = 0,actY,1 do
- moveDown()
- end
- if actY == 0 then
- moveDown()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment