Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- qclear - Use a quarry frame preparation to clear an area.
- -- This program places the landmarks and then waits for the user
- -- to enable the frame with a right-click.
- -- Then it waits for the user to place the quarry machine block.
- -- The user must then power the quarry to get it started.
- -- The turtle then breaks the quarry machine block as soon as
- -- the quarry frame appears.
- -- Quarry land markers must be placed in slot 2
- -- At least 3 solid blocks (maybe dirt) must be placed in slot 3
- -- Rev: 1.0
- args = {...}
- nArgs = #args
- height = 10
- length = 20
- width = 7
- quarrySlot = 1
- markerSlot = 2
- blockSlot = 3
- conduitSlot = 4
- x = 0
- y = 0
- z = 0
- length = 0
- width = 0
- height = 0
- goodToGo = true
- function getArgs()
- result = true
- if nArgs == 0 or (nArgs == 1 and args[1]== "help") then
- print("Clear blocks from length, width, height")
- print("Place 4 quarry land markers in slot 2")
- print("Place 4 solid blocks (dirt?) in slot 3")
- print("Usage: qclear <length><width><height>")
- return false
- end
- if nArgs ~= 3 then
- print("Usage: qclear <length><width><height>")
- return false
- end
- length = tonumber(args[1])
- if length == nil then
- print("\"", args[1], "\" is not a valid length")
- return false
- end
- if length < 1 then
- print("length must be a positive number greater than zero")
- result = false
- end
- width = tonumber(args[2])
- if width == nil then
- print("\"", args[2], "\" is not a valid width")
- return false
- end
- if width < 1 then
- print("width must be a positive number greater than zero")
- result = false
- end
- height = tonumber(args[3])
- if height == nil then
- print("\"", args[3], "\" is not a valid height")
- return false
- end
- return result
- end
- function forward(nBlocks)
- for i=1,nBlocks do
- for j=1,10 do
- if turtle.forward() then
- break
- else
- turtle.dig()
- end
- end
- end
- end
- function up(nBlocks)
- for i=1,nBlocks do
- for j=1,10 do
- if turtle.up() then
- break
- else
- turtle.digUp()
- end
- end
- y = y+1
- end
- end
- function down(nBlocks)
- for i=1,nBlocks do
- for j=1,10 do
- if turtle.down() then
- break
- else
- turtle.digDown()
- end
- end
- y = y-1
- end
- end
- function placeMarkers()
- turtle.turnLeft()
- forward(1)
- turtle.turnLeft()
- forward(1)
- turtle.turnLeft()
- turtle.turnLeft()
- if not turtle.detectDown() then
- turtle.select(blockSlot)
- turtle.placeDown()
- end
- up(1)
- turtle.select(markerSlot)
- turtle.placeDown()
- up(height-1)
- turtle.select(blockSlot)
- turtle.placeDown()
- up(1)
- turtle.select(markerSlot)
- turtle.placeDown()
- forward(length+1)
- while y > 0 do
- down(1)
- end
- turtle.turnRight()
- forward(1)
- placeLandMarker()
- forward(width)
- turtle.turnRight()
- forward(length+1)
- placeBlock()
- turtle.turnRight()
- forward(1)
- placeLandMarker()
- forward(width-1)
- turtle.turnRight()
- -- turtle.forward(1)
- end
- function placeBlock()
- turtle.select(blockSlot)
- turtle.placeDown()
- end
- function placeLandMarker()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(markerSlot)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function prep()
- for i=1,height do
- turtle.up()
- end
- placeLandMarker()
- for i=1,length do
- turtle.dig()
- turtle.forward()
- x = x+1
- end
- placeLandMarker()
- x = x-1
- while x > 0 do
- turtle.back()
- x = x-1
- end
- turtle.turnRight()
- for i=1,width do
- turtle.dig()
- turtle.forward()
- z = z+1
- end
- placeLandMarker()
- z = z-1
- while z > 0 do
- turtle.back()
- z = z-1
- end
- end
- function waitForQuarryBlock()
- turtle.turnLeft()
- turtle.turnLeft()
- forward(1)
- turtle.turnRight()
- turtle.dig()
- turtle.select(quarrySlot)
- while not turtle.detect() do
- sleep(0)
- end
- turtle.turnRight()
- end
- function waitForQuarryFrame()
- while not turtle.detect() do
- sleep(0)
- end
- end
- if getArgs() == goodToGo then
- placeMarkers()
- print("Waiting for quarry block to be placed...")
- waitForQuarryBlock()
- print("Waiting for quarry frame to form...")
- waitForQuarryFrame()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- print("Quarry has been decommissioned.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement