Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a = {}
- local args = {...}
- local counter = 4
- local numbering = 5
- local posX = 0
- local posY = 0
- local posZ = 0
- local centerX = 0
- local centerY = 0
- local centerZ = 0
- local buildHeight = 0
- posX, posY, posZ = gps.locate(5)
- local startX = posX
- local startY = posY
- local startZ = posZ
- local direction = 0
- local startDirect = 0
- local inventory = 1
- function a.orient()
- turtle.forward()
- posX, posY, posZ = gps.locate(5)
- if posX>startX then
- direction = 0
- end
- if posZ>startZ then
- direction = 1
- end
- if posX<startX then
- direction = 2
- end
- if posZ<startZ then
- direction = 3
- end
- startDirect = direction
- turtle.back()
- end
- function a.moveTo(targetX,targetY,targetZ)
- posX, posY, posZ = gps.locate(5)
- print(gps.locate(5))
- while posY > targetY do
- turtle.down()
- posX, posY, posZ = gps.locate(5)
- end
- while posY < targetY do
- turtle.up()
- posX, posY, posZ = gps.locate(5)
- end
- if posX > targetX then
- a.rotateTo(2)
- end
- if posX < targetX then
- a.rotateTo(0)
- end
- while posX ~= targetX do
- turtle.forward()
- posX, posY, posZ = gps.locate(5)
- end
- if posZ > targetZ then
- a.rotateTo(3)
- end
- if posZ < targetZ then
- a.rotateTo(1)
- end
- while posZ ~= targetZ do
- turtle.forward()
- posX, posY, posZ = gps.locate(5)
- end
- end
- function a.rotateTo(targetD)
- while direction ~= targetD do
- if direction > 3 then
- direction = 0
- end
- if direction < 0 then
- direction = 3
- end
- if direction < targetD then
- direction = direction + 1
- turtle.turnRight()
- end
- if direction > targetD then
- direction = direction - 1
- turtle.turnLeft()
- end
- end
- end
- function a.buildSquare(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- for x=0, (size-1) do
- for z=0, (size-1) do
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- if posX == targetX-(math.floor(size/2+size%2)) or posX == targetX+(math.floor(size/2)-size%2) or posZ == targetZ-(math.floor(size/2+size%2)) or posZ == targetZ+(math.floor(size/2)-size%2) then
- a.buildDown()
- end
- end
- end
- end
- function a.buildPlatform(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- for x=0, size-1 do
- for z=0, size-1 do
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- a.buildDown()
- end
- end
- end
- function a.digHole(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- for x=0, size-1 do
- for z=0, size-1 do
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- turtle.digDown()
- end
- end
- end
- function a.buildDiamond(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- size = size+2
- for x=0, size-1 do
- for z=0, size-1 do
- diff = math.abs(x-math.floor(size/2))
- print(diff)
- if z > diff and z < size-diff-1 then
- a.moveTo(targetX+x-(math.floor(size/2+size%2))+math.floor(size/2-size%2), targetY, targetZ+z-(math.floor(size/2+size%2))+math.floor(size/2-size%2))
- a.buildDown()
- end
- end
- end
- end
- function a.buildAntiDiamond(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- size = size+2
- for x=0, size-1 do
- for z=0, size-1 do
- diff = math.abs(x-math.floor(size/2))
- print(diff)
- if z < diff and z > size-diff-1 then
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- a.buildDown()
- end
- end
- end
- end
- function a.digDiamond(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- size = size+2
- for x=0, size-1 do
- for z=0, size-1 do
- diff = math.abs(x-math.floor(size/2))
- print(diff)
- if z > diff and z < size-diff-1 then
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- a.buildDown()
- end
- end
- end
- end
- function a.digAntiDiamond(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- size = size+2
- for x=0, size-1 do
- for z=0, size-1 do
- diff = math.abs(x-math.floor(size/2))
- print(diff)
- if z < diff and z > size-diff-1 then
- a.moveTo(targetX+x-(math.floor(size/2+size%2)), targetY, targetZ+z-(math.floor(size/2+size%2)))
- a.buildDown()
- end
- end
- end
- end
- function a.buildDiamondTest(targetX, targetY, targetZ, size)
- a.moveTo(targetX, targetY, targetZ)
- size = size+2
- for x=0, size-1 do
- for z=0, size-1 do
- diff = math.abs(x-math.floor(size/2))
- print(diff)
- if z > diff and z < size-diff-1 then
- a.moveTo(targetX+x-(math.floor(size/2)), targetY, targetZ+z-(math.floor(size/2)))
- a.buildDown()
- end
- end
- end
- end
- function a.buildDown()
- if turtle.getItemCount() == 0 then
- inventory = inventory+1
- end
- if inventory > 16 then
- a.checkSupply()
- else
- turtle.select(inventory)
- turtle.placeDown()
- end
- end
- function a.checkComp(name)
- found = false
- for i=1, 16 do
- turtle.select(i)
- block = turtle.getItemDetail(turtle.getSelectedSlot())
- if name == block.name then
- inventory = i
- found = true
- end
- end
- if found == false then
- posX, posY, posZ = gps.locate(5)
- tempDirect = direction
- tempX = posX
- tempY = posY
- tempZ = posZ
- a.moveTo(startX,tempY+1,startZ)
- a.moveTo(startX,startY,startZ)
- a.rotateTo(startDirect)
- turtle.turnLeft()
- print("Give me more")
- print(name)
- while turtle.getItemCount() <10 do
- sleep(1)
- end
- turtle.turnRight()
- a.moveTo(startX,tempY+1,startZ)
- a.moveTo(tempX,tempY+1,tempZ)
- a.moveTo(tempX,tempY,tempZ)
- end
- end
- function a.placeComp(name)
- a.checkComp(name)
- turtle.place()
- end
- function a.checkSupply()
- turtle.select(16)
- if turtle.getItemCount() < 10 then
- posX, posY, posZ = gps.locate(5)
- tempX = posX
- tempY = posY
- tempZ = posZ
- a.moveTo(startX,tempY,startZ)
- a.moveTo(startX,startY,startZ)
- a.rotateTo(startDirect)
- turtle.turnLeft()
- print("Not enough blocks")
- while turtle.getItemCount() <10 do
- turtle.suck()
- sleep(1)
- end
- turtle.turnRight()
- a.moveTo(startX,tempY,startZ)
- a.moveTo(tempX,tempY,tempZ)
- inventory = 1
- end
- turtle.select(inventory)
- end
- function a.checkIfComp(block)
- if block == "minecraft:glass_pane" then
- return true
- end
- if block == "minecraft:dispenser" then
- return true
- end
- if block == "minecraft:observer" then
- return true
- end
- end
- a.orient()
- for i=0, tonumber(args[1]) do
- turtle.forward()
- end
- posX, posY, posZ = gps.locate(5)
- centerX, centerY, centerZ = gps.locate(5)
- print("Starting building")
- if tonumber(args[2]) == 1 then
- for y = 0, 20 do
- a.buildSquare(centerX, centerY+y, centerZ, 5)
- buildHeight = y
- end
- a.buildPlatform(centerX, centerY+buildHeight, centerZ, 21)
- a.digHole(centerX, centerY+buildHeight, centerZ, 3)
- buildHeight = buildHeight+1
- a.buildSquare(centerX, centerY+buildHeight, centerZ, 21)
- buildHeight = buildHeight+1
- a.buildSquare(centerX, centerY+buildHeight, centerZ, 21)
- buildHeight = buildHeight+1
- a.buildSquare(centerX, centerY+buildHeight, centerZ, 21)
- buildHeight = buildHeight+1
- a.buildPlatform(centerX, centerY+buildHeight, centerZ, 21)
- posX, posY, posZ = gps.locate(5)
- a.moveTo(startX,posY,startZ)
- a.moveTo(startX,startY,startZ)
- end
- if tonumber(args[2]) == 2 then
- for y=0, 20 do
- a.buildDiamond(centerX, centerY+y, centerZ, 3)
- a.moveTo(centerX, centerY+y, centerZ)
- turtle.digDown()
- buildHeight = y
- end
- for y=0, 6 do
- a.buildDiamond(centerX, posY, centerZ, 21)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- a.buildDiamond(centerX, posY+1, centerZ, 5)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- a.buildDiamond(centerX, posY+1, centerZ, 5)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- buildHeight = y
- end
- a.buildDiamond(centerX, posY+1, centerZ, 42)
- end
- if tonumber(args[2]) == 3 then
- a.buildDiamondTest(centerX, centerY, centerZ, tonumber(args[3]))
- a.moveTo(centerX, centerY+1, centerZ)
- a.buildDown()
- end
- if tonumber(args[2]) == 4 then
- for y=0, 20 do
- a.buildDiamondTest(centerX, centerY+y, centerZ, 3)
- a.moveTo(centerX, centerY+y, centerZ)
- turtle.digDown()
- buildHeight = y
- end
- for y=0, 6 do
- a.buildDiamondTest(centerX, posY, centerZ, 21)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- a.buildDiamondTest(centerX, posY+1, centerZ, 5)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- a.buildDiamondTest(centerX, posY+1, centerZ, 5)
- a.moveTo(centerX, posY, centerZ)
- turtle.digDown()
- a.moveTo(centerX, posY+1, centerZ)
- buildHeight = y
- end
- a.buildDiamondTest(centerX, posY+1, centerZ, 42)
- end
Add Comment
Please, Sign In to add comment