Advertisement
Guest User

Turtle quarry

a guest
Oct 9th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. xCoord = -178
  2. yCoord = 81
  3. zCoord = 157
  4.  
  5. zDiff = {-1, 0, 1, 0}
  6. xDiff = {0, 1, 0, -1}
  7. orientation = 4
  8. orientations = {"north", "east", "south", "west"}
  9.  
  10. function left()
  11.   orientation = orientation - 1
  12.  orientation = (orientation - 1) % 4
  13.  orientation = orientation + 1
  14.  turtle.turnLeft()
  15. end
  16.  
  17. function right()
  18.  
  19.  orientation = - 1
  20.  orientation = (orientation + 1) % 4
  21.  orientation = orientation + 1
  22.  turtle.turnRight()
  23. end
  24.  
  25. function moveForward()
  26.  
  27.   xCoord = xCoord + xDiff[orientation]
  28.   zCoord = zCoord + zDiff[orientation]
  29.   turtle.dig()
  30.  moved = false
  31.  while not(moved) do
  32.  moved = turtle.forward()
  33.  moved = print("I Tried to move")
  34. end
  35.   print("I moved :D")
  36. end
  37. function.moveUp()
  38.    yCoord = yCoord + 1
  39.    turtle.digUp()
  40.    moved = false
  41.  while not(moved) do
  42.  moved = turtle.up()
  43.  end
  44. end
  45. function moveDown()
  46.   yCoord = yCoord - 1
  47.   turtle.digDown()
  48.  moved = false
  49.  while not(moved) do
  50.  turtle.down()
  51.   end
  52. end
  53. function look(direction)
  54.   while direction ~=orientations[orientation] do
  55.   right()
  56.   end
  57. end
  58. function goto(xTarget, zTarget, yTarget)
  59.   while yTarget < yCoord do
  60.   moveDown()
  61. end
  62.  while yTarget > yCoord do
  63.  moveUp()
  64.   end
  65. end
  66. if xTarget < xCoord then
  67. look("west")
  68. while xTarget > xCoord do
  69.   moveForward()
  70. end
  71. end
  72. if zTarget < zCoord then
  73.   look("north")
  74. while zTarget < zCoord do
  75.   moveForward()
  76.   end
  77. end
  78. if zTarget > zCoord then
  79.   look("south")
  80. while zTarget > zCoord do
  81. moveForward()
  82.   end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement