Advertisement
visiongaming43

Untitled

May 21st, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. -- Making Methods
  2. function move(amount)
  3. if (amount < 0) then
  4. turtle.turnRight()
  5. turtle.turnRight()
  6. end
  7. amount = math.abs(amount)
  8. while (amount > 0) do
  9. turtle.forward()
  10. amount = amount - 1
  11. end
  12. end
  13.  
  14. -- DEFAULTS TO TURNING TURTLE NORTH ( Z - AXIS )
  15. function faceNorth()
  16. local startX, startY, startZ = gps.locate()
  17. turtle.dig()
  18. turtle.forward()
  19. local endX, endY, endZ = gps.locate()
  20. if(endX < startX) then turtle.Left()
  21. elseif (endX > startX) then turtle.turnRight()
  22. elseif (endZ < startZ) then turtle.turnRight() turtle.turnRight()
  23. end
  24. end
  25.  
  26. -- MOVES TO COORDINATES X, Y, Z
  27. function moveTo(x, y, z)
  28. faceNorth()
  29. local curX, curY, curZ = gps.locate()
  30. local xDist = math.abs(x - curX)
  31. local yDist = math.abs(y - curY)
  32. local zDist = math.abs(z - curZ)
  33. local xMethod
  34. local yMethod
  35. local zMethod
  36. if (curX > x) then xMethod = turtle.forward() else xMethod = turtle.back() end
  37. if (curY > y) then yMethod = turtle.down() else yMethod = turtle.up() end
  38. if(curZ > z) then zMethod = turtle.forward() else zMethod = turtle.back() end
  39.  
  40. while (xDist > 0) do
  41. xMethod()
  42. xDist = xDist - 1
  43. end
  44. while (yDist > 0) do
  45. yMethod()
  46. yDist = yDist - 1
  47. end
  48. while (zDist > 0) do
  49. zMethod()
  50. zDist = zDist - 1
  51. end
  52. end
  53.  
  54. function getSeedIndex()
  55. for slot = 1, 16, 1 do
  56. local item = turtle.getItemDetail(slot)
  57. if ( (item ~= nil) and ( (string.match(item.name, "seed") ) or (string.match(item.name, "potato") ) or (string.match(item.name, "carrot") ) ) ) then
  58. return slot
  59. end
  60. end
  61. end
  62.  
  63. function getCrop()
  64. local isBlock, data = turtle.inspectDown()
  65. if(isBlock)then
  66. if ( ( string.match(data.name, "croptopia:") or string.match(data.name, "wheat") or string.match(data.name, "potato") or string.match(data.name, "carrot")) and data['state']['age'] == 7) then
  67. turtle.digDown()
  68. seedIndex = getSeedIndex()
  69. if(seedIndex ~= nil) then
  70. turtle.select(seedIndex)
  71. turtle.placeDown()
  72. end
  73. end
  74. else
  75. seedIndex = getSeedIndex()
  76. if(seedIndex ~= nil) then
  77. turtle.digDown()
  78. turtle.select(seedIndex)
  79. turtle.placeDown()
  80. end
  81. end
  82. end
  83.  
  84. function resetPos()
  85. local file = fs.open("Settings", "r")
  86. local startX = file.readLine()
  87. local startY = file.readLine()
  88. local startZ = file.readLine()
  89. moveTo(startX, startY, startZ)
  90. end
  91.  
  92. moveTo(-3041, 63, -20806)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement