Advertisement
Igneus

Untitled

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