Advertisement
Igneus

Untitled

Jul 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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. if turtle.getItemCount(i) > 0
  33. then
  34. local item = this.getItemDetail()
  35. print(item["name"])
  36. print(itemName)
  37. if item["name"] == itemName
  38. then
  39. print(i)
  40. return i
  41. end
  42. end
  43. end
  44.  
  45. return -1
  46. end
  47.  
  48. function placeInventory(slot)
  49. this.select(slot)
  50. this.placeDown()
  51. end
  52.  
  53. function harvestCrop(seedType)
  54. local harvested = harvest()
  55. if harvested
  56. then
  57. local stick = getItemLocation("AgriCraft:cropsItem")
  58. sleep(2)
  59. local seed = getItemLocation(seedType)
  60.  
  61. if stick > 0
  62. then
  63. placeInventory(stick)
  64. end
  65.  
  66. if seed > 0
  67. then
  68. placeInventory(seed)
  69. end
  70. end
  71. end
  72.  
  73. function leftUTurn()
  74. this.turnLeft()
  75. this.forward()
  76. this.turnLeft()
  77. end
  78.  
  79. function rightUTurn()
  80. this.turnRight()
  81. this.forward()
  82. this.turnRight()
  83. end
  84.  
  85. function advance(x,y,turn)
  86. if y == 7
  87. then
  88. if x % 2 == 0
  89. then
  90. rightUTurn()
  91. else
  92. leftUTurn()
  93. end
  94. else
  95. this.forward()
  96. end
  97. end
  98.  
  99. function harvestEnderGrid()
  100. local left = this.turnLeft()
  101. local right = this.turnRight()
  102. for i=1,7,1
  103. do
  104. for j=1,7,1
  105. do
  106. harvestCrop("magicalcrops:EndermanSeeds")
  107. advance(i,j)
  108. end
  109. end
  110. end
  111.  
  112. --this.refuel()
  113. --harvestEnderGrid()
  114. print(getItemLocation("magicalcrops:EndermanSeeds"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement