funkd0ct0r

Untitled

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