funkd0ct0r

Untitled

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