Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Author: Stravides
- Program: Turtle EnderQuarry Placement
- Date: 20th March 2014
- Usage: free for non profit or non commercial.
- Summary of functionality:
- Will do different actions depending upon World (Nether or overworld)
- Overworld expects to be at a height not to need digging or cutting
- Nether expects to have to dig in front and below and to be at a height.
- Program will place the enderquarry, tesseract wire up the 2, however it is assumed that the
- tesseract will have receive power and send items already set and redstone turned off.
- The turtle will then place the fences needed to make up to a 64x64 quarry - this WILL bypass any towny or other faction setting
- it is your responsibility to make sure that when you set the turtle free - there will be no
- griefing.
- The Turtle will place The enderquarry directly where you place the turtle. This will be the lower leftmost part
- of the quarry. By default, the quarry will then extend right for maxwidth-1 then turn left
- --]]
- --[[
- Turtle Slots
- Item Slots
- 4 Full stacks fences 1-4
- Enderquarry 9
- Gold Pipe x 2 10
- Tesseract Pre configured 11
- --]]
- -- Variables
- local arg = { ... }
- xlen = tonumber(arg[1]) -- get x Length
- ylen = tonumber(arg[2]) -- get y Length
- minQSize=7
- if xlen or ylen < minQSize then
- print("Sorry minimum quarry size is "..minQSize.."x"..minQSize)
- end
- clockwise = false
- if arg[3] == "-c" then
- clockwise = true
- elseif arg[3] == "-cf" then
- cost_only = true
- end
- -- set up Turtle Slots
- fslot = 1
- maxFenceSlots=4
- EQslot=9 -- EnderQuarry
- GPSlot=10 -- Gold Pipe
- TSlot=11 -- Tesseract
- foundSlot = false
- positionx = radius --no fking idea <--
- positiony = radius --no fking idea <--
- facing = 0
- -- Constants
- -- Functions
- function turnRightTrack()
- turtle.turnRight()
- facing = facing + 1
- if facing >= 4 then
- facing = 0
- end
- end
- function turnLeftTrack()
- turtle.turnLeft()
- facing = facing - 1
- if facing < 0 then
- facing = 3
- end
- end
- function safeForward()
- success = false
- while not success do
- success = turtle.forward()
- if not success then
- print("Blocked attempting to move forward.")
- print("Please clear and press enter to continue.")
- io.read()
- end
- end
- end
- function safeBack()
- success = false
- while not success do
- success = turtle.back()
- if not success then
- print("Blocked attempting to move back.")
- print("Please clear and press enter to continue.")
- io.read()
- end
- end
- end
- function safeUp()
- success = false
- while not success do
- success = turtle.up()
- if not success then
- print("Blocked attempting to move up.")
- print("Please clear and press enter to continue.")
- io.read()
- end
- end
- end
- function safeDown()
- success = false
- while not success do
- success = turtle.down()
- if not success then
- print("Blocked attempting to move down.")
- print("Please clear and press enter to continue.")
- io.read()
- end
- end
- end
- function moveY(targety)
- if targety == positiony then
- return
- end
- if (facing ~= 0 and facing ~= 2) then -- check axis
- turnRightTrack()
- end
- while targety > positiony do
- if facing == 0 then
- safeForward()
- else
- safeBack()
- end
- positiony = positiony + 1
- end
- while targety < positiony do
- if facing == 2 then
- safeForward()
- else
- safeBack()
- end
- positiony = positiony - 1
- end
- end
- function moveX(targetx)
- if targetx == positionx then
- return
- end
- if (facing ~= 1 and facing ~= 3) then -- check axis
- turnRightTrack()
- end
- while targetx > positionx do
- if facing == 1 then
- safeForward()
- else
- safeBack()
- end
- positionx = positionx + 1
- end
- while targetx < positionx do
- if facing == 3 then
- safeForward()
- else
- safeBack()
- end
- positionx = positionx - 1
- end
- end
- function navigateTo(targetx, targety)
- -- Cost calculation mode - don't move
- if cost_only then
- return
- end
- if facing == 0 or facing == 2 then -- Y axis
- moveY(targety)
- moveX(targetx)
- else
- moveX(targetx)
- moveY(targety)
- end
- end
- function placeBlock()
- -- Cost calculation mode - don't move
- blocks = blocks + 1
- if cost_only then
- return
- end
- if turtle.getItemCount(cslot) == 0 then
- foundSlot = false
- while not foundSlot do
- for i = 1,4 do
- if turtle.getItemCount(i) > 0 then
- foundSlot = i
- break
- end
- end
- if not foundSlot then
- -- No resources
- print("Out of building materials. Please refill and press enter to continue.")
- io.read()
- end
- end
- cslot = foundSlot
- turtle.select(foundSlot)
- end
- turtle.placeDown()
- end
- function checkFenceStocks()
- if turtle.getItemCount(fslot) == 0 then
- foundSlot = false
- while not foundSlot do
- for i = 1,maxFenceSlots do
- if turtle.getItemCount(i) > 0 then
- foundSlot = i
- break
- end
- end
- if not foundSlot then
- -- No resources
- print("Out of Fences. Please refill slots 1-" ..maxFenceSlots.." and press enter to continue.")
- io.read()
- end
- end
- cslot = foundSlot
- turtle.select(foundSlot)
- end
- end
- function calculateFences(xlen,ylen)
- fence=(2*xlen)+(2*ylen)-5 -- minus 5 for corners and the quarry
- print("You are going to need " ..fence.." fences. Put fences in slots 1-4 and then Press Enter")
- print("Make sure you have set me up correctly")
- io.read()
- end
- function setFences(xlen,ylen)
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- for i = 1, (xlen-2)/2 do
- turtle.dig()
- safeForward()
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- end
- turnLeftTrack()
- for i = 1, (ylen-1) do
- turtle.dig()
- safeForward()
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- end
- turnLeftTrack()
- for i = 1, (xlen-1) do
- turtle.dig()
- safeForward()
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- end
- turnLeftTrack()
- for i = 1, (ylen-1) do
- turtle.dig()
- safeForward()
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- end
- turnLeftTrack()
- for i = 1, (xlen-2)/2 do
- turtle.dig()
- safeForward()
- checkFenceStocks()
- turtle.digDown()
- turtle.placeDown()
- end
- end
- function setupQuarry()
- turtle.safeForward()
- turtle.safeForward()
- turnLeftTrack()
- turtle.digDown()
- turtle.safeDown()
- turtle.safeBack()
- turtle.select(EQslot)
- turtle.place()
- safeUp()
- turtle.select(Tslot)
- turtle.placeDown()
- safeUp()
- turtle.select(GPslot)
- turtle.placeDown()
- safeForward()
- turtle.placeDown()
- turnRightTrack()
- turnRightTrack()
- safeForward()
- safeForward()
- safeDown()
- end
- -- Runtime
- calculateFences(xlen,ylen)
- setFences(xlen,ylen)
- setupQuarry() -- This sets the quarry etc so make sure that the area is clear
- print("Click the EnderQuarry to start")
Advertisement
Add Comment
Please, Sign In to add comment