funkd0ct0r

Untitled

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