Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Chunk land mark
- local args = {...}
- -- Check if there arguments
- if #args ~= 1 then
- print("Usage: landmark <L/R>")
- return
- end
- dir = "L"
- dir = args[1]
- if dir == "l" or dir == "L" then
- dir = "L"
- else
- dir = "R"
- end
- local function tryDig()
- while turtle.detect() do
- if turtle.dig() then
- sleep(0.3)
- else
- return false
- end
- end
- return true
- end
- local function tryDigUp()
- while turtle.detectUp() do
- if turtle.digUp() then
- sleep(0.3)
- else
- return false
- end
- end
- return true
- 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
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- 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 Quarry Setup." )
- end
- end
- local function tryForward()
- refuel()
- while not turtle.forward() do
- if turtle.detect() then
- if not tryDig() then
- return false
- end
- elseif turtle.attack() then
- -- collect()
- else
- sleep( 0.3 )
- end
- end
- return true
- end
- local function cornerMark()
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- if dir == "L" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- tryDig()
- tryDigUp()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.back()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for i=1,2 do
- for n=1,17 do
- if n<16 then
- tryDig()
- tryDigUp()
- if not tryForward() then
- print( "Aborting Setup." )
- break
- end
- else
- print( "Segment complete." )
- end
- end
- cornerMark()
- for n=1,17 do
- if n<16 then
- tryDig()
- tryDigUp()
- if not tryForward() then
- print( "Aborting Setup." )
- break
- end
- else
- print( "Segment complete." )
- end
- end
- cornerMark()
- end
- turtle.select(2)
- turtle.placeDown()
- print( "Chunk delimited." )
Advertisement
Add Comment
Please, Sign In to add comment