Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --for i = 1,16 do
- --turtle.select(i)
- --slotItemName = turtle.getItemDetail()
- --if not(slotItemName.name == "minecraft:diamond") then
- --turtle.drop()
- --end
- --end
- toNotMine = {"turtle","computer","chest","furnace","wool"}
- toKeep = {"diamond","coal","iron","lead","redstone","copper","gold","galena"}
- function orient()
- initX,initY,initZ = gps.locate()
- turtle.forward()
- newX,newY,newZ = gps.locate()
- turtle.back()
- xOrient = initX - newX
- zOrient = initZ - newZ
- if xOrient == 1 then
- turtle.turnRight()
- turtle.turnRight() end
- if zOrient == 1 then turtle.turnRight() end
- if zOrient == -1 then turtle.turnLeft() end
- end
- function mine()
- dontMineAhead = 0
- success1, blockAhead = turtle.inspect()
- for i = 1,#toNotMine do
- if success1 == true then
- if string.match(tostring(blockAhead.name),toNotMine[i]) ~= nil then dontMineAhead = 1
- end
- end
- end
- if dontMineAhead ~= 1 then turtle.dig() end
- if dontMineAhead == 1 then avoidAhead() end
- end
- function mineAbove()
- dontMineAbove = 0
- success2, blockAbove = turtle.inspectUp()
- for i = 1,#toNotMine do
- if success2 == true then
- if string.match(tostring(blockAbove.name),toNotMine[i]) ~= nil then dontMineAbove = 1
- end
- end
- end
- if dontMineAbove ~= 1 then turtle.digUp() end
- if dontMineAbove == 1 then avoidAbove() end
- end
- function mineBelow()
- dontMineBelow = 0
- success3, blockBelow = turtle.inspectDown()
- for i = 1,#toNotMine do
- if success3 == true then
- if string.match(tostring(blockBelow.name),toNotMine[i]) ~= nil then dontMineBelow = 1
- end
- end
- end
- if dontMineBelow ~= 1 then turtle.digDown() end
- if dontMineBelow == 1 then avoidBelow() end
- end
- function avoidAhead()
- end
- function avoidAbove()
- end
- function avoidBelow()
- end
- function mineComplete()
- mine()
- mineAbove()
- mineBelow()
- end
- ----------------------------------
- turtle.select(1)
- turtle.refuel()
- xDir = 1
- yDir = 1
- zDir = 1
- x,y,z = gps.locate()
- Coords2 = {50,100,50}
- orient()
- if x > Coords2[1] then xDis = x - Coords2[1] xDir = 0 end
- if x <= Coords2[1] then xDis = Coords2[1] - x end
- if xDir == 0 then turtle.turnRight() turtle.turnRight() end
- for i =1,xDis do
- mineComplete() turtle.forward()
- end
- if z > Coords2[3] then zDis = z - Coords2[3] zDir = 0 end
- if z <= Coords2[3] then zDis = Coords2[3] - z end
- if ((zDir == 0 and xDir == 0) or (zDir == 1 and xDir == 1)) then turtle.turnLeft() zTurn = 1 end
- if ((zDir == 1 and xDir == 0)or(zDir == 0 and zDir == 1)) then turtle.turnRight() zTurn = 0 end
- for i =1,zDis do
- mineComplete() turtle.forward()
- end
- if y > Coords2[2] then yDis = y - Coords2[2] yDir = 0 end
- if y <= Coords2[2] then yDis = Coords2[2] - y end
- for i = 1,yDis do
- if yDir == 1 then mineAbove() turtle.up() end
- if yDir == 0 then mineBelow() turtle.down() end
- end
- if zTurn == 1 then turtle.turnRight() end
- if zTurn == 0 then turtle.turnLeft() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement