Advertisement
jakikoske

myMiningTest

Dec 8th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. local position = vector.new(gps.locate(0))
  2. local orientation
  3.  
  4. function move()
  5.     while(turtle.forward() == false) do
  6.             turtle.dig()
  7.             turtle.suck()
  8.     end
  9. end
  10.  
  11. function getPosition()
  12.     position = vector.new(gps.locate(0))
  13.     position.x = position.x -1
  14. end
  15.  
  16. function getOrientation()
  17.     helpPos = position
  18.     move()
  19.     helpPos = helpPos - getPosition()
  20.     if helpPos.x > 0 then
  21.         orientation = 3
  22.     else
  23.         orientation = 0
  24.        
  25.     end
  26. end
  27.  
  28. getOrientation()
  29.  
  30. function getPositionOffset()
  31.     getPosition()
  32.     position.x = position.x%16
  33.     position.y = position.y%16
  34. end
  35.  
  36. function addOrientation(i)
  37.     orientation = orientation + i
  38.     if orientation == 4 then
  39.         orientation = 0
  40.     end
  41.     if orientation == -1 then
  42.         orientation = 3
  43.     end
  44. end
  45.  
  46. function turnRight()
  47.     turtle.turnRight()
  48.     addOrientation(1)
  49. end
  50.  
  51. function setOrientationX()
  52.     while orientation ~= 1 do
  53.         turnRight()
  54.     end
  55. end
  56.  
  57. function goTo00()
  58.     getPositionOffset()
  59.     setOrientationX()
  60.     for i = 1, position.x do
  61.         move()
  62.     end
  63. end
  64.  
  65. goTo00()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement