Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Goals of the Mining Turtle:
- -Mine 2x1 mine shafts 54 blocks deep
- -Place torches to prevent mob spawning
- -Scan for ores (Hard to implement)
- -Drop Cobblestone, Sand, Dirt, and Gravel
- -Refuel as needed (Not needed yet)
- -Place items in a chest near the entrance of each shaft
- -Take in an input of the amount of shafts to build on one wall (Not yet)
- -Replace any walls as needed on the top or sides of the shaft
- -Return to start position when done.
- --]]
- --Coordinates and Orientation
- startXCoord =
- startYCoord =
- startZCoord =
- xCoord = startXCoord
- yCoord = startYCoord
- zCoord = startZCoord
- orientation =
- orientations{0,1,2,3}
- xDiff = {-1,0-,1,0} --Changes in xCoord when moving in an orientation 0 = north
- zDiff = {0,1,0,-1} --Changes in yCoord when moving in an orientation 0 = north
- --Movement Functions
- function left()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function right()
- orientation = orientation - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function look(direction)
- while direction ~= orientations[orientation]
- right()
- end
- end
- function moveForward()
- xCoord = xCoord + xDiff[orientation]
- zCoord = zCoord + zDiff[orientation]
- turtle.dig()
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- end
- function moveUp()
- yCoord = yCoord + 1
- turtle.digUp()
- moved = false
- while not(moved) do
- moved = turtle.up()
- end
- end
- function moveDown()
- yCoord = yCoord - 1
- turtle.digUp()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- end
- function moveTo(xTarget, yTarget, zTarget)
- while yCoord < yTarget do
- moveUp()
- end
- while yCoord > yTarget do
- moveDown()
- end
- if xCoord > xTarget then
- look(3)
- while xCoord > xTarget do
- moveForward()
- end
- end
- if xCoord < xTarget
- look(1)
- while xCoord < xTarget do
- moveForward()
- end
- end
- end
- --Building the shaft functions
- function placeTorch()
- turtle.select(16)
- turtle.placeDown()
- end
- function digPortion()
- turtle.digUp()
- moveForward()
- turtle.digUp()
- moveForward()
- turtle.digUp()
- moveForward()
- moveUp()
- turnLeft()
- for i = 1, 5 do
- moveForward()
- end
- turnLeft()
- turnLeft()
- for i = 1, 10 do
- moveForward()
- end
- turnLeft()
- turnLeft()
- for i = 1, 5 do
- moveForward()
- end
- turnRight()
- moveDown()
- moveForward()
- end
- function digUpToTorch()
- placeTorch()
- for i = 1, 3 do
- digPortion()
- end
- end
- for i = 1, 4 do
- digUpToTorch()
- end
- digPortion()
- turtle.digUp()
- moveForward()
- turtle.digUp()
- moveForward()
- moveUp()
- for i = 1, 5 do
- moveForward()
- end
- moveTo(startXCoord, startYCoord, startZCoord)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement