Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- cd disk
- -- edit quarry
- -- Episode 17
- xCoord = -1668 // Starting x Coord
- zCoord = -484 // Starting z Coord
- yCoord = 127 // Starting y Coord
- orientation = 4 -- Starting orientation
- orientations = {"North","East","South","West"} -- Strings of the orientations
- zDiff = {-1, 0, +1, 0}
- xDiff = {0, +1, 0, -1}
- Length = 9
- Width = 10
- yMin = yCoord
- xQuarry = 999
- zQuarry = 999
- yQuarry = 150
- xProgress = 999
- zProgress = 999
- yProgress = 150
- oProgress = 1
- xHome = xCoord
- zHome = zCoord
- yHome = yCoord
- yTravel = 85
- function inventoryFull()
- turtle.select(9)
- full = turtle.getItemCount(9) > 0
- turtle.select(1)
- return full
- end
- 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.turnRight()
- 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.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- if yMin > yCoord then
- yMin = yCoord
- end
- end
- function look(direction)
- while direction ~= orientations[orientation] do
- right()
- end
- end
- function goto(xTarget,zTarget,yTarget)
- while yTarget < yCoord do
- moveDown()
- end
- while yTarget > yCoord do
- moveUp()
- end
- if xTarget < xCoord then
- look("West")
- while xTarget < xCoord do
- moveForward()
- end
- end
- if xTarget > xCoord then
- look("East")
- while xTarget > xCoord do
- moveForward()
- end
- end
- if zTarget < zCoord then
- look("North")
- while zTarget < zCoord do
- moveForward()
- end
- end
- if zTarget > zCoord then
- look("South")
- while zTarget > zCoord do
- moveForward()
- end
- end
- end
- function returnItems()
- xProgress = xCoord
- zProgress = zCoord
- yProgress = yCoord
- oProgress = orientation
- goto(xHome, zHome, yTravel)
- goto(xHome, zHome, yHome)
- for i = 1,9 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- goto(xProgress, zProgress, yTravel)
- goto(xProgress, zProgress, yProgress)
- look(orientations[oProgress])
- end
- function digLine()
- for i = 1,Length do
- if inventoryFull() then
- returnItems()
- end
- moveForward()
- end
- end
- function digLayer()
- for i = 1,Width do
- digLine()
- if (i%2) == 1 and i < Width then
- left()
- moveForward()
- left()
- elseif i < Width then
- right()
- moveForward()
- right()
- end
- end
- goto(xQuarry, zQuarry, yCoord)
- look("North")
- moveDown()
- end
- function digQuarry(xTarget, zTarget, yTarget)
- xQuarry = xTarget
- zQuarry = zTarget
- yQuarry = yTarget
- goto(xQuarry,zQuarry,yTravel)
- goto(xQuarry,zQuarry,yQuarry)
- while yMin > 5 do
- digLayer()
- end
- goto(xQuarry, zQuarry, yQuarry)
- yMin = 999
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement