Advertisement
Igneus

Untitled

Jul 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. this = turtle
  2.  
  3. function sleep(n)
  4. local t = os.clock()
  5. while os.clock() - t <= n do
  6. -- nothing
  7. end
  8. end
  9.  
  10. function harvest()
  11. local success, t = this.inspectDown()
  12. if success
  13. then
  14. print("inspect = true")
  15. if t.name == "AgriCraft:crops"
  16. then
  17. print("name = true")
  18. if t.metadata == 7
  19. then
  20. print("metadata = true")
  21. this.digDown()
  22. return true
  23. end
  24. end
  25. end
  26. return false
  27. end
  28.  
  29. function getItemLocation(itemName)
  30. for i=1,16,1
  31. do
  32. local item = this.getItemDetail()
  33. print(item.name)
  34. print(itemName)
  35. if item.name == itemName
  36. then
  37. print(i)
  38. return i
  39. end
  40. end
  41.  
  42. return -1
  43. end
  44.  
  45. function getCropSticksInventoryLocation()
  46. return getItemLocation("AgriCraft:cropsItem")
  47. end
  48.  
  49. function getSeedInventoryLocation(seedType)
  50. return getItemLocation(seedType)
  51. end
  52.  
  53. function placeInventory(slot)
  54. this.select(slot)
  55. this.placeDown()
  56. end
  57.  
  58. function harvestCrop(seedType)
  59. local harvested = harvest()
  60. if harvested
  61. then
  62. local stick = getCropSticksInventoryLocation()
  63. sleep(10)
  64. local seed = getSeedInventoryLocation(seedType)
  65.  
  66. if stick > 0
  67. then
  68. placeInventory(stick)
  69. end
  70.  
  71. if seed > 0
  72. then
  73. placeInventory(seed)
  74. end
  75. end
  76. end
  77.  
  78. function leftUTurn()
  79. this.turnLeft()
  80. this.forward()
  81. this.turnLeft()
  82. end
  83.  
  84. function rightUTurn()
  85. this.turnRight()
  86. this.forward()
  87. this.turnRight()
  88. end
  89.  
  90. function advance(x,y,turn)
  91. if y == 7
  92. then
  93. if x % 2 == 0
  94. then
  95. rightUTurn()
  96. else
  97. leftUTurn()
  98. end
  99. else
  100. this.forward()
  101. end
  102. end
  103.  
  104. function harvestEnderGrid()
  105. local left = this.turnLeft()
  106. local right = this.turnRight()
  107. for i=1,7,1
  108. do
  109. for j=1,7,1
  110. do
  111. harvestCrop("magicalcrops:EndermanSeeds")
  112. advance(i,j)
  113. end
  114. end
  115. end
  116.  
  117. harvestEnderGrid()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement