Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. --[[
  2. SeedBreeder
  3. This is a AgriCraft seed breeder program for ComputerCraft/OpenComputers. Check Wiki for more information.
  4. Wiki: github.com/robokop92/SeedBreeder/wiki
  5. MADE BY: robokop92
  6. This is the OPENCOMPUTERS Version
  7. --]]
  8. component = require("component")
  9. shell = require("shell")
  10. side = require("sides")
  11. t = require("term")
  12. c = require("computer")
  13. r = require("robot")
  14. ser = require("serialization")
  15. fs = require("filesystem")
  16. inv = component.inventory_controller
  17. gen = component.generator
  18.  
  19. version = "1.0.0"
  20.  
  21. ----------------------------------------------------
  22. ------------------SOME VARIABLES--------------------
  23. ----------------------------------------------------
  24.  
  25. numOfSubGenerations = 40
  26. sleepAmountBetweenGenerations = 10
  27. sleepAmountWhenWachingSeeds = 5
  28.  
  29.  
  30. local args, opt= shell.parse(...)
  31. if args[1] ~= nil then
  32. numOfSubGenerations = args[1]*4
  33. end
  34. if args[2] ~= nil then
  35. sleepAmountBetweenGenerations = args[2]
  36. end
  37. if args[3] ~= nil then
  38. sleepAmountWhenWachingSeeds = args[3]
  39. end
  40.  
  41. startpos = {x = 0, y = -1, z = 2}
  42. pos = {x = 0, y = -1, z = 2}
  43. fl = {pos = {}}
  44. fl.pos[0] = {x = 0, y = 0, z = 1}
  45. fl.pos[1] = {x = -1, y = 0, z = 0}
  46. fl.pos[2] = {x = 0, y = 0, z = -1}
  47. fl.pos[3] = {x = 1, y = 0, z = 0}
  48. fl.pos[4] = {x = 0, y = 0, z = 0}
  49. fl.pos[5] = {x = 0, y = 1, z = 0}
  50.  
  51. cpos = {}
  52. cpos.anlzer = {x = -1, y = 0, z = 1}
  53. cpos.bin = {x = -1, y = 0, z = -1}
  54. cpos.chest = {x = 1, y = 0, z = -1}
  55.  
  56. slot = {sticks = {}, fuel = 1, rake = 4, seeds = 5, seedsExtra = 6}
  57. slot.sticks[1] = 2
  58. slot.sticks[2] = 3
  59.  
  60. ----------------------------------------------------
  61. -----------------LANG VARIABLES---------------------
  62. ----------------------------------------------------
  63. lang_noFuel = "Please insert a valid fuel in slot "..slot.fuel.."!"
  64. lang_noSticks = "Please insert Crop Sticks in slot "..slot.sticks[1].." or "..slot.sticks[2].."!"
  65. lang_noRake = "Please insert a Hand Rake in slot "..slot.rake.."!"
  66. lang_noSeed = "Please insert ONLY 1 valid seeds in slot "..slot.seeds.."!"
  67. lang_timeBtwGen = "Waiting time between generations: "
  68. lang_curGen = "Current generation: "
  69. lang_line = "---------------------------------------"
  70. ----------------------------------------------------
  71. ----------------ERROR MESSAGES----------------------
  72. ----------------------------------------------------
  73. function noFuel()
  74. while not gen.insert(1) do
  75. t.clear()
  76. t.setCursor(1,1)
  77. t.write(lang_noFuel)
  78. os.sleep(1)
  79. end
  80. t.clear()
  81. return true
  82. end
  83. function noSticks()
  84. while not tidySticks() do
  85. t.clear()
  86. t.setCursor(1,1)
  87. t.write(lang_noSticks)
  88. os.sleep(1)
  89. end
  90. t.clear()
  91. return true
  92. end
  93. function noRake()
  94. while not compareItemInSlot("AgriCraft:handRake",slot.rake) do
  95. t.clear()
  96. t.setCursor(1,1)
  97. t.write(lang_noRake)
  98. os.sleep(1)
  99. end
  100. t.clear()
  101. return true
  102. end
  103. function noSeeds()
  104. while not checkCount(slot.seeds,1) do
  105. t.clear()
  106. t.setCursor(1,1)
  107. t.write(lang_noSeed)
  108. os.sleep(1)
  109. end
  110. if seeds() >= 1 then
  111. t.clear()
  112. return true
  113. else
  114. noSeeds()
  115. end
  116. end
  117. ----------------------------------------------------
  118. --------------INVENTORY CONTROLLLER-----------------
  119. ----------------------------------------------------
  120. function compareItemInSlot(item,slot) -- Compares $item with the item in $slot
  121. itemInfo = inv.getStackInInternalSlot(slot)
  122. if itemInfo ~= nil then --If $slot has item
  123. --print("Comparing: "..item.." AND: "..itemInfo.name)
  124. if item == itemInfo.name then -- If $item matches item name in $slot
  125. return true
  126. end
  127. end
  128. return false
  129. end
  130. function checkCount(slot,count)
  131. itemInfo = inv.getStackInInternalSlot(slot)
  132. if itemInfo ~= nil and itemInfo.size >= count then
  133. return true
  134. end
  135. return false
  136. end
  137. function count(slot)
  138. itemInfo = inv.getStackInInternalSlot(slot)
  139. if itemInfo ~= nil then
  140. return itemInfo.size
  141. end
  142. return 0
  143. end
  144. function transferItem(fromSlot,toSlot)
  145. lastSl = r.select(fromSlot)
  146. r.transferTo(toSlot,64)
  147. r.select(lastSl)
  148. end
  149.  
  150. function isEquipEmpty()
  151. lastSl = r.select(slot.seeds)
  152. inv.equip()
  153. if checkCount(slot.seeds,1) then
  154. return false
  155. end
  156. return true
  157. end
  158.  
  159. ----------------------------------------------------
  160. ----------------BASIC ROBOT COMMANDS----------------
  161. ----------------------------------------------------
  162.  
  163. function putInAnlzer()
  164. lastSl = r.select(slot.seeds)
  165. succes = r.dropDown()
  166. r.select(lastSl)
  167. return succes
  168. end
  169.  
  170. function takeFromAnlzer()
  171. lastSl = r.select(slot.seeds)
  172. succes = inv.suckFromSlot(side.bottom,1)
  173. r.select(lastSl)
  174. return succes
  175. end
  176. function analyze()
  177. move(cpos.anlzer)
  178. print("Analyzing")
  179. if putInAnlzer() then
  180. os.sleep(1.7)
  181. return takeFromAnlzer()
  182. end
  183. return false
  184. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement