Advertisement
funkd0ct0r

Untitled

Mar 23rd, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- setup is turtle facing apiary, with a (large, maybe dimensional storage) chest beneath the turtle
  2. -- QTRQHPhM
  3. -- RwTbaqpP
  4.  
  5. local apiary = peripheral.wrap("front")
  6. local chest = peripheral.wrap("bottom")
  7. local maxDrones = 6
  8. local minDrones = 3
  9.  
  10. bees = {}
  11. stacks = {}
  12. shutdownMsg = nil
  13.  
  14. function addParent(parent, offspring)
  15. if not bees[parent] then
  16. bees[parent] = {
  17. --name = parent,
  18. score = 0,
  19. mutateFrom = {}
  20. }
  21. end
  22. end
  23.  
  24. function addOffspring(offspring, parentss)
  25. if bees[offspring] then
  26. for i, parents in ipairs(parentss) do
  27. table.insert(bees[offspring].mutateFrom, parents)
  28. end
  29. else
  30. bees[offspring] = {
  31. score = 0,
  32. mutateFrom = parentss
  33. }
  34. end
  35. for i, parents in ipairs(parentss) do
  36. for i, parent in ipairs(parents) do
  37. addParent(parent, offspring)
  38. end
  39. end
  40. end
  41.  
  42.  
  43.  
  44.  
  45. -- produce combinations from 1 or 2 lists
  46. function choose(list, list2)
  47. local newList = {}
  48. if list2 then
  49. for i = 1, #list2 do
  50. for j = 1, #list do
  51. if list[j] ~= list[i] then
  52. table.insert(newList, {list[j], list2[i]})
  53. end
  54. end
  55. end
  56. else
  57. for i = 1, #list do
  58. for j = i, #list do
  59. if list[i] ~= list[j] then
  60. table.insert(newList, {list[i], list[j]})
  61. end
  62. end
  63. end
  64. end
  65. return newList
  66. end
  67.  
  68.  
  69. --bee list from Master Apiarist Database v3.1
  70. --Forestry v2.3.0.7 (683)
  71. --Extra Bees v1.8-dev2
  72. --Magic Bees v2.1.7 (build 78)
  73.  
  74. addOffspring("Common", choose({"Forest", "Meadows", "Modest", "Wintry", "Tropical", "Marshy", "Water", "Rocky", "Mystical", "Sorcerous", "Unusual", "Attuned"}))
  75. addOffspring("Cultivated", choose({"Common"}, {"Forest", "Meadows", "Modest", "Wintry", "Tropical", "Marshy", "Water", "Rocky", "Mystical", "Sorcerous", "Unusual", "Attuned"}))
  76.  
  77. addOffspring("Noble", {{"Common", "Cultivated"}})
  78. addOffspring("Majestic", {{"Noble", "Cultivated"}})
  79. addOffspring("Imperial", {{"Noble", "Majestic"}})
  80. addOffspring("Diligent", {{"Common", "Cultivated"}})
  81. addOffspring("Unweary", {{"Diligent", "Cultivated"}})
  82. addOffspring("Industrious", {{"Diligent", "Unweary"}})
  83. addOffspring("Heroic", {{"Steadfast", "Valiant"}})
  84. addOffspring("Sinister", choose({"Cultivated"}, {"Modest", "Tropical"}))
  85. addOffspring("Fiendish", choose({"Sinister"}, {"Cultivated", "Modest", "Tropical"}))
  86. addOffspring("Frugal", choose({"Modest"}, {"Sinister", "Fiendish"}))
  87. addOffspring("Demonic", {{"Sinister", "Fiendish"}})
  88. addOffspring("Austere", {{"Modest", "Frugal"}})
  89. addOffspring("Exotic", {{"Austere", "Tropical"}})
  90. addOffspring("Edenic", {{"Exotic", "Tropical"}})
  91. addOffspring("Spectral", {{"Hermitic", "Ender"}})
  92. addOffspring("Phantasmal", {{"Spectral", "Ender"}})
  93. addOffspring("Icy", {{"Industrious", "Wintry"}})
  94. addOffspring("Glacial", {{"Icy", "Wintry"}})
  95. addOffspring("Vindictive", {{"Monastic", "Demonic"}})
  96. addOffspring("Vengeful", choose({"Vindictive"}, {"Demonic", "Monastic"}))
  97. addOffspring("Avenging", {{"Vengeful", "Vindictive"}})
  98. addOffspring("Leporine", {{"Meadows", "Forest"}})
  99. addOffspring("Merry", {{"Wintry", "Forest"}})
  100. addOffspring("Tipsy", {{"Wintry", "Meadows"}})
  101. addOffspring("Tricky", {{"Sinister", "Common"}})
  102. addOffspring("Rural", {{"Meadows", "Diligent"}})
  103. addOffspring("Secluded", {{"Monastic", "Austere"}})
  104. addOffspring("Hermitic", {{"Monastic", "Secluded"}})
  105. addOffspring("Arid", {{"Meadows", "Modest"}})
  106. addOffspring("Barren", {{"Arid", "Common"}})
  107. addOffspring("Desolate", {{"Arid", "Barren"}})
  108. addOffspring("Decaying", {{"Desolate", "Modest"}})
  109. addOffspring("Skeletal", {{"Desolate", "Frugal"}})
  110. addOffspring("Creepy", {{"Desolate", "Austere"}})
  111. addOffspring("Decomposing", {{"Gnawing", "Common"}})
  112. addOffspring("Tolerant", {{"Rocky", "Diligent"}})
  113. addOffspring("Robust", {{"Rocky", "Tolerant"}})
  114. addOffspring("Resilient", {{"Imperial", "Robust"}})
  115. addOffspring("Corroded", {{"Resilient", "Forest"}})
  116. addOffspring("Tarnished", {{"Resilient", "Marshy"}})
  117. addOffspring("Rusty", {{"Resilient", "Meadows"}})
  118. addOffspring("Leaden", {{"Resilient", "Unweary"}})
  119. addOffspring("Galvanized", {{"Tarnished", "Cultivated"}})
  120. addOffspring("Impregnable", {{"Resilient", "Noble"}})
  121. addOffspring("Invincible", {{"Resilient", "Ender"}})
  122. addOffspring("Glittering", {{"Corroded", "Imperial"}})
  123. addOffspring("Shining", {{"Rusty", "Imperial"}})
  124. addOffspring("Valuable", {{"Glittering", "Shining"}})
  125. addOffspring("Lapis", {{"Resilient", "Water"}})
  126. addOffspring("Emerald", {{"Lapis", "Noble"}})
  127. addOffspring("Ruby", {{"Emerald", "Austere"}})
  128. addOffspring("Sapphire", {{"Emerald", "Ocean"}})
  129. addOffspring("Diamond", {{"Lapis", "Imperial"}})
  130. addOffspring("Unstable", {{"Austere", "Rocky"}})
  131. addOffspring("Nuclear", {{"Unstable", "Rusty"}})
  132. addOffspring("Radioactive", {{"Nuclear", "Glittering"}})
  133. addOffspring("Ancient", {{"Noble", "Diligent"}})
  134. addOffspring("Primeval", {{"Ancient", "Noble"}})
  135. addOffspring("Prehistoric", {{"Primeval", "Majestic"}})
  136. addOffspring("Relic", {{"Prehistoric", "Imperial"}})
  137. addOffspring("Fossilised", {{"Primeval", "Growing"}})
  138. addOffspring("Resinous", {{"Primeval", "Fungal"}})
  139. addOffspring("Oily", {{"Primeval", "Ocean"}})
  140. addOffspring("Distilled", {{"Oily", "Industrious"}})
  141. addOffspring("Refined", {{"Oily", "Distilled"}})
  142. addOffspring("Elastic", {{"Refined", "Resinous"}})
  143. addOffspring("River", {{"Water", "Common"}})
  144. addOffspring("Ocean", {{"Water", "Diligent"}})
  145. addOffspring("Stained", {{"Ebony", "Ocean"}})
  146. addOffspring("Growing", {{"Diligent", "Forest"}})
  147. addOffspring("Thriving", {{"Growing", "Rural"}})
  148. addOffspring("Blooming", {{"Thriving", "Growing"}})
  149. addOffspring("Sweetened", {{"Valiant", "Diligent"}})
  150. addOffspring("Sugary", {{"Sweetened", "Diligent"}})
  151. addOffspring("Ripening", {{"Sugary", "Forest"}})
  152. addOffspring("Fruity", {{"Ripening", "Rural"}})
  153. addOffspring("Farmed", {{"Cultivated", "Rural"}})
  154. addOffspring("Bovine", {{"Rural", "Water"}})
  155. addOffspring("Caffeinated", {{"Tropical", "Rural"}})
  156. addOffspring("Minty", {{"Tropical", "Farmed"}})
  157. addOffspring("Damp", {{"Common", "Marshy"}})
  158. addOffspring("Boggy", {{"Damp", "Marshy"}})
  159. addOffspring("Fungal", {{"Boggy", "Damp"}})
  160. addOffspring("Furious", {{"Embittered", "Sinister"}})
  161. addOffspring("Volcanic", {{"Embittered", "Furious"}})
  162. addOffspring("Malicious", {{"Sinister", "Tropical"}})
  163. addOffspring("Infectious", {{"Malicious", "Tropical"}})
  164. addOffspring("Virulent", {{"Malicious", "Infectious"}})
  165. addOffspring("Viscous", {{"Water", "Exotic"}})
  166. addOffspring("Glutinous", {{"Viscous", "Exotic"}})
  167. addOffspring("Sticky", {{"Viscous", "Glutinous"}})
  168. addOffspring("Corrosive", {{"Virulent", "Sticky"}})
  169. addOffspring("Caustic", {{"Corrosive", "Fiendish"}})
  170. addOffspring("Acidic", {{"Corrosive", "Caustic"}})
  171. addOffspring("Excited", {{"Cultivated", "Valiant"}})
  172. addOffspring("Energetic", {{"Excited", "Valiant"}})
  173. addOffspring("Frigid", {{"Wintry", "Diligent"}})
  174. addOffspring("Absolute", {{"Ocean", "Frigid"}})
  175. addOffspring("Shadowed", {{"Tolerant", "Sinister"}})
  176. addOffspring("Darkened", {{"Shadowed", "Embittered"}})
  177. addOffspring("Abyssal", {{"Shadowed", "Darkened"}})
  178. addOffspring("Maroon", {{"Forest", "Valiant"}})
  179. addOffspring("Saffron", {{"Meadows", "Valiant"}})
  180. addOffspring("Prussian", {{"Water", "Valiant"}})
  181. addOffspring("Natural", {{"Tropical", "Valiant"}})
  182. addOffspring("Ebony", {{"Rocky", "Valiant"}})
  183. addOffspring("Bleached", {{"Wintry", "Valiant"}})
  184. addOffspring("Sepia", {{"Marshy", "Valiant"}})
  185. addOffspring("Amber", {{"Maroon", "Saffron"}})
  186. addOffspring("Turquoise", {{"Natural", "Prussian"}})
  187. addOffspring("Indigo", {{"Maroon", "Prussian"}})
  188. addOffspring("Slate", {{"Ebony", "Bleached"}})
  189. addOffspring("Azure", {{"Prussian", "Bleached"}})
  190. addOffspring("Lavender", {{"Maroon", "Bleached"}})
  191. addOffspring("Lime", {{"Natural", "Bleached"}})
  192. addOffspring("Fuchsia", {{"Indigo", "Lavender"}})
  193. addOffspring("Ashen", {{"Slate", "Bleached"}})
  194. addOffspring("Celebratory", {{"Austere", "Excited"}})
  195. addOffspring("Jaded", {{"Ender", "Relic"}})
  196. addOffspring("Glowering", {{"Furious", "Excited"}})
  197. addOffspring("Hazardous", {{"Austere", "Desolate"}})
  198. addOffspring("Lustered", {{"Resilient", "Unweary"}})
  199. addOffspring("Abnormal", {{"Secluded", "Ender"}})
  200. addOffspring("Spatial", {{"Abnormal", "Hermitic"}})
  201. addOffspring("Quantum", {{"Spatial", "Spectral"}})
  202. addOffspring("Eldritch", choose({"Cultivated"}, {"Mystical", "Sorcerous", "Unusual", "Attuned"}))
  203. addOffspring("Esoteric", {{"Cultivated", "Eldritch"}})
  204. addOffspring("Mysterious", {{"Eldritch", "Esoteric"}})
  205. addOffspring("Arcane", {{"Esoteric", "Mysterious"}})
  206. addOffspring("Charmed", {{"Cultivated", "Eldritch"}})
  207. addOffspring("Enchanted", {{"Eldritch", "Charmed"}})
  208. addOffspring("Supernatural", {{"Charmed", "Enchanted"}})
  209. addOffspring("Ethereal", {{"Arcane", "Supernatural"}})
  210. addOffspring("Watery", {{"Supernatural", "Ethereal"}})
  211. addOffspring("Earthen", {{"Supernatural", "Ethereal"}})
  212. addOffspring("Firey", {{"Supernatural", "Ethereal"}})
  213. addOffspring("Windy", {{"Supernatural", "Ethereal"}})
  214. addOffspring("Pupil", {{"Monastic", "Arcane"}})
  215. addOffspring("Scholarly", {{"Arcane", "Pupil"}})
  216. addOffspring("Savant", {{"Pupil", "Scholarly"}})
  217. addOffspring("Aware", {{"Ethereal", "Attuned"}})
  218. addOffspring("Spirit", choose({"Aware"}, {"MystEtherealical", "Attuned"}))
  219. addOffspring("Soul", {{"Aware", "Spirit"}})
  220. addOffspring("Skulking", {{"Modest", "Eldritch"}})
  221. addOffspring("Ghastly", {{"Skulking", "Ethereal"}})
  222. addOffspring("Spidery", {{"Tropical", "Skulking"}})
  223. addOffspring("Smouldering", {{"Skulking", "Hateful"}})
  224. addOffspring("Timely", {{"Imperial", "Ethereal"}})
  225. addOffspring("Lordly", {{"Imperial", "Timely"}})
  226. addOffspring("Doctoral", {{"Timely", "Lordly"}})
  227. addOffspring("Infernal", {{"Infernal", "ves"}})
  228. addOffspring("Hateful", {{"Infernal", "Eldritch"}})
  229. addOffspring("Spiteful", {{"Infernal", "Hateful"}})
  230. addOffspring("Withering", {{"Demonic", "Spiteful"}})
  231. addOffspring("Oblivion", {{"Oblivion", "ves"}})
  232. addOffspring("Nameless", {{"Ethereal", "Oblivion"}})
  233. addOffspring("Abandoned", {{"Oblivion", "Nameless"}})
  234. addOffspring("Forlorn", {{"Nameless", "Abandoned"}})
  235. addOffspring("Draconic", {{"Imperial", "Abandoned"}})
  236. addOffspring("Ferrous", {{"Common", "Industrious"}})
  237. addOffspring("Auric", {{"Minium", "Plumbum"}})
  238. addOffspring("Cuprum", {{"Industrious", "Meadows"}})
  239. addOffspring("Stannum", {{"Industrious", "Forest"}})
  240. addOffspring("Argentum", {{"Imperial", "Modest"}})
  241. addOffspring("Plumbum", {{"Stannum", "Common"}})
  242. addOffspring("Aluminum", {{"Industrious", "Cultivated"}})
  243. addOffspring("Ardite", {{"Industrious", "Infernal"}})
  244. addOffspring("Cobalt", {{"Imperial", "Infernal"}})
  245. addOffspring("Manyullyn", {{"Ardite", "Cobalt"}})
  246. addOffspring("Diamandi", {{"Austere", "Auric"}})
  247. addOffspring("Esmeraldi", {{"Austere", "Argentum"}})
  248. addOffspring("Apatine", {{"Rural", "Cuprum"}})
  249. addOffspring("Mutable", {{"Unusual", "Eldritch"}})
  250. addOffspring("Transmuting", {{"Unusual", "Mutable"}})
  251. addOffspring("Crumbling", {{"Unusual", "Mutable"}})
  252. addOffspring("Invisible", {{"Mystical", "Mutable"}})
  253. addOffspring("Aer", {{"Windy", "Windy"}})
  254. addOffspring("Ignis", {{"Firey", "Firey"}})
  255. addOffspring("Aqua", {{"Watery", "Watery"}})
  256. addOffspring("Solum", {{"Earthen", "Earthen"}})
  257. addOffspring("Ordered", {{"Ethereal", "Arcane"}})
  258. addOffspring("Chaotic", {{"Ethereal", "Supernatural"}})
  259. addOffspring("Brainy", {{"Skulking", "Pupil"}})
  260. addOffspring("Batty", {{"Skulking", "Windy"}})
  261. addOffspring("Poultry", {{"Common", "Skulking"}})
  262. addOffspring("Beefy", {{"Common", "Skulking"}})
  263. addOffspring("Porcine", {{"Common", "Skulking"}})
  264. addOffspring("Minium", {{"Frugal", "Eldritch"}})
  265.  
  266.  
  267.  
  268.  
  269. function findAvailableParent(species, score, type)
  270.  
  271. for i, stack in pairs(stacks) do
  272. if stack.beeInfo.displayName == species then
  273. if type then
  274. if string.find(stack.name, type) then
  275. return species, nil, score
  276. end
  277. else
  278. return species, nil, score
  279. end
  280. end
  281. end
  282.  
  283. local aScore, aParent, aOffspring
  284. local beeScore = 99999
  285. local beeParent = nil
  286. local beeOffspring = nil
  287.  
  288. for i, parents in ipairs(bees[species].mutateFrom) do
  289. aParent, aOffspring, aScore = findAvailableParent(parents[1], score + 1, type)
  290. if aScore < beeScore then
  291. beeScore = aScore
  292. beeParent = aParent
  293. beeOffspring = aOffspring
  294. end
  295. aParent, aOffspring, aScore = findAvailableParent(parents[2], score + 1, type)
  296. if aScore < beeScore then
  297. beeScore = aScore
  298. beeParent = aParent
  299. beeOffspring = aOffspring
  300. end
  301. end
  302. if beeOffspring == nil then
  303. beeOffspring = species
  304. end
  305. return beeParent, beeOffspring, beeScore
  306. end
  307.  
  308.  
  309. local function findSpecies(species)
  310. local princessIndex = nil
  311. local droneIndex = nil
  312.  
  313. for i, stack in pairs(stacks) do
  314. if stack.beeInfo.displayName == species then
  315. if string.find(stack.name, "Princess") then
  316. princessIndex = i
  317. end
  318. if string.find(stack.name, "Drone") then
  319. droneIndex = i
  320. end
  321. end
  322. end
  323. return princessIndex, droneIndex
  324. end
  325.  
  326. local function breedSpecies(parent1, parent2)
  327. local princess1 = nil
  328. local princess2 = nil
  329. local drone1 = nil
  330. local drone2 = nil
  331.  
  332. princess1, drone1 = findSpecies(parent1)
  333. princess2, drone2 = findSpecies(parent2)
  334.  
  335. if not (princess1 and drone2) then
  336. princess1 = princess2
  337. drone2 = drone1
  338. end
  339.  
  340. print("Breeding " .. parent1 .. " with " .. parent2)
  341.  
  342. if princess1 and drone2 then
  343. chest.pushItem("up", princess1, 1) --todo check against description
  344. turtle.drop()
  345. chest.pushItem("up", drone2, 1) --todo check against description
  346. turtle.drop()
  347. return true
  348. end
  349. return false
  350. end
  351.  
  352. local function findExtraBee(type, msg)
  353. local counts = {}
  354. local bestcount = 0
  355. local bestspecies = nil
  356.  
  357. for i, stack in pairs(stacks) do
  358. if string.find(stack.name, type) then
  359. if counts[stack.beeInfo.displayName] then
  360. counts[stack.beeInfo.displayName] = counts[stack.beeInfo.displayName] + 1
  361. else
  362. counts[stack.beeInfo.displayName] = 1
  363. end
  364. if counts[stack.beeInfo.displayName] > bestcount then
  365. bestcount = counts[stack.beeInfo.displayName]
  366. bestspecies = stack.beeInfo.displayName
  367. end
  368. end
  369. end
  370. if bestcount < 2 then
  371. shutdownMsg = "Need more " .. type .. "s!";
  372. else
  373. if msg == "Used" or bestcount > maxDrones then
  374. print(msg .. " Extra " .. bestspecies .. " " .. type)
  375. end
  376. end
  377. return bestspecies, bestcount
  378. end
  379.  
  380. local function purebreed(species)
  381. local princessCount = 0
  382. local droneCount = 0
  383.  
  384. --count how many i have
  385.  
  386. for i, stack in pairs(stacks) do
  387. if stack.beeInfo.displayName == species then
  388. if string.find(stack.name, "Princess") then
  389. princessCount = princessCount + stack.qty
  390. end
  391. if string.find(stack.name, "Drone") then
  392. droneCount = droneCount + stack.qty
  393. end
  394. end
  395. end
  396.  
  397. if princessCount >= 1 and droneCount >= minDrones then
  398. return true
  399. end
  400.  
  401. print("Attempting to purebreed " .. species)
  402.  
  403. if princessCount >= 1 and droneCount >= 1 then
  404. breedSpecies(species, species)
  405. return false
  406. end
  407.  
  408. --find something to breed it with, an available parent, or an extra bee
  409.  
  410. local parent1, offspring, score
  411. if(princessCount >= 1) then
  412. parent1, offspring, score = findAvailableParent(species, 0, "Drone")
  413. if score == 99999 then
  414. parent1, score = findExtraBee("Drone", "Used")
  415. else
  416. local princess1, drone1 = findSpecies(parent1)
  417. if princess1 and drone2 and not purebreed(parent1) then
  418. return false
  419. end
  420. end
  421. else
  422. parent1, offspring, score = findAvailableParent(species, 0, "Princess")
  423. if score == 99999 then
  424. parent1, score = findExtraBee("Princess", "Used")
  425. else
  426. local princess1, drone1 = findSpecies(parent1)
  427. if princess1 and drone2 and not purebreed(parent1) then
  428. return false
  429. end
  430. end
  431. end
  432. if shutdownMsg then
  433. return false
  434. end
  435.  
  436. breedSpecies(species, parent1)
  437. return false
  438. end
  439.  
  440. local function targetSpecies(species)
  441. local parent1
  442. local parent2 = nil
  443.  
  444. --find the highest level bee i have that is a parent to species
  445. --offspring would be the next step after parent on the way to species
  446.  
  447. local parent1, offspring, score = findAvailableParent(species, 0, nil)
  448. if score == 0 then
  449. --found species
  450. return true
  451. end
  452. if score == 99999 then
  453. shutdownMsg = "No available parents for " .. species
  454. return false
  455. end
  456.  
  457. print("Targeting Species " .. offspring)
  458.  
  459. local princess1, drone1 = findSpecies(parent1)
  460. local princess2, drone2
  461.  
  462. --find which bee i need to breed parent1 with to get offspring, showing preference for bees that i own
  463.  
  464. for i, parents in ipairs(bees[offspring].mutateFrom) do
  465. if parents[1] == parent1 then
  466. princess2, drone2 = findSpecies(parents[2])
  467. if (princess1 and drone2) or (princess2 and drone1) then
  468. parent2 = parents[2]
  469. break
  470. end
  471. if not parent2 then
  472. parent2 = parents[2]
  473. end
  474. if princess2 or drone2 then
  475. parent2 = parents[2]
  476. end
  477. end
  478. if parents[2] == parent1 then
  479. princess2, drone2 = findSpecies(parents[1])
  480. if (princess1 and drone2) or (princess2 and drone1) then
  481. parent2 = parents[1]
  482. break
  483. end
  484. if not parent2 then
  485. parent2 = parents[1]
  486. end
  487. if princess2 or drone2 then
  488. parent2 = parents[1]
  489. end
  490. end
  491.  
  492. end
  493.  
  494. princess2, drone2 = findSpecies(parent2)
  495.  
  496. if (princess1 and drone2) or (princess2 and drone1) then
  497. --i have both bees i need so breed it now
  498. if princess1 and drone1 and not purebreed(parent1) then
  499. return false
  500. end
  501. if princess2 and drone2 and not purebreed(parent2) then
  502. return false
  503. end
  504. breedSpecies(parent1, parent2)
  505. return false
  506. end
  507.  
  508. --i have the species but not princess or drone, so purebreed it
  509. if princess2 or drone2 then
  510. purebreed(parent2)
  511. return false
  512. end
  513.  
  514. --i dont have the species i need to breed with parent, so target it
  515. targetSpecies(parent2)
  516. return false
  517. end
  518.  
  519. local function dropExtraDrones()
  520.  
  521. local species, count = findExtraBee("Drone", "Dropping")
  522. shutdownMsg = nil
  523.  
  524. if count <= maxDrones then
  525. return
  526. end
  527.  
  528. for i, stack in pairs(stacks) do
  529. if stack.beeInfo.displayName == species and string.find(stack.name, "Drone") then
  530. chest.pushItem("up", i, 1)
  531. turtle.dropUp()
  532. count = count - 1
  533. if count <= maxDrones then
  534. return
  535. end
  536. end
  537. end
  538.  
  539. end
  540.  
  541.  
  542. local function main(species)
  543.  
  544. for slot = 1, 16 do
  545. if turtle.getItemCount(slot) > 0 then
  546. turtle.select(slot)
  547. turtle.dropDown()
  548. end
  549. end
  550. turtle.select(1)
  551.  
  552. local apiarystacks
  553.  
  554. while(1) do
  555.  
  556. --test for breeding in progress
  557. apiarystacks = apiary.getAllStacks()
  558. while apiarystacks[1] do
  559. sleep(1)
  560. while(turtle.suck()) do
  561. turtle.dropDown()
  562. end
  563.  
  564. apiarystacks = apiary.getAllStacks()
  565. end
  566.  
  567. --clear apiary
  568. while(turtle.suck()) do
  569. turtle.dropDown()
  570. end
  571.  
  572. stacks = chest.getAllStacks()
  573.  
  574. if targetSpecies(species) then
  575. if purebreed(species) then
  576. shutdownMsg = "Breeding complete: " .. species
  577. end
  578. end
  579.  
  580. if(shutdownMsg) then
  581. print(shutdownMsg)
  582. break
  583. end
  584.  
  585. dropExtraDrones()
  586.  
  587. sleep(1)
  588. end
  589. end
  590.  
  591. local species = ...
  592. if species == nil then
  593. print("Usage")
  594. print(" programname species")
  595. return
  596. end
  597. if bees[species] == nil then
  598. print("Species does not exist in database")
  599. end
  600.  
  601. main(species)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement