pirga

авто выведение пчёл нужной породы

Jul 9th, 2019 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.36 KB | None | 0 0
  1. -- (c) Max K https://github.com/asgmax
  2.  
  3. local component = require("component")
  4. local computer = require("computer")
  5. local term = require("term")
  6. local event = require("event")
  7. local gpu = component.gpu
  8. local serialization = require("serialization")
  9. local unicode = require("unicode")
  10.  
  11. local const = {
  12.     strongPrincessCount = 3, -- >=
  13.     strongCount = 10,
  14.     strongCountRoof = 15,
  15.     trashInterface = component.proxy("3abf0df6-977c-4134-9302-a889711d87b8"),
  16.     analyzerInterface = component.proxy("0c09070e-5632-4079-b318-94c969529887"),
  17.     analyzerChestSide = "South", -- relative to analyzerInterface
  18.     exportSide = "WEST", -- side to export for test purposes
  19.     houseSide = "North", -- side of apiary (relative to interface)
  20.     trashSide = "East", -- side of chest (relative to intTrash (trashing interface)) to drop notNatural princesses
  21. }
  22.  
  23. --North - север
  24. --South - юг
  25. --East - восток
  26. --West – запад
  27.  
  28. local int = {
  29.     [1] = component.proxy("b754146f-2956-475d-b527-43630f57a836"),
  30. }
  31.  
  32. local apiary = {
  33.     [1] = component.proxy("4231c194-8bcc-48f2-bc24-a3b287f96434"),
  34. }
  35.  
  36. function isBee(table) if table.individual then return true else return false end end
  37. function isNatural(table) if table.individual.isNatural == true then return true else return false end end
  38. function isAnalyzed(table) if table.individual.isAnalyzed == true then return true else return false end end
  39. function isDrone(table) if string.find(table.label,"Drone") then return true else return false end end
  40. function isPrincess(table) if string.find(table.label,"Princess") then return true else return false end end
  41. function isQueen(table) if string.find(table.label,"Queen") then return true else return false end end
  42. function isPure(table) if table.individual.isAnalyzed and table.individual.active.species == table.individual.inactive.species then return true else return false end end
  43. function isUnpure(table) if table.individual.isAnalyzed and table.individual.active.species ~= table.individual.inactive.species then return true else return false end end
  44. function isSpecie(table,specie) if string.lower(specie) == string.lower(table.individual.displayName) then return true else return false end end
  45. function isAl1(table,specie) if string.lower(specie) == string.lower(table.individual.active.species) then return true else return false end end
  46. function isAl2(table,specie) if string.lower(specie) == string.lower(table.individual.inactive.species) then return true else return false end end
  47.  
  48. function isAlx(table,specie) if string.lower(specie) == string.lower(table.individual.active.species) or string.lower(specie) == string.lower(table.individual.inactive.species) then return true else return false end end
  49. function isPureSpec(table,specie) if string.lower(specie) == string.lower(table.individual.active.species) and string.lower(specie) == string.lower(table.individual.inactive.species) then return true else return false end end
  50.  
  51. function isVanilla(table) if isSpecie(table,"meadows") or isSpecie(table,"forest") then return true else return false end end
  52. function canFind(string1,string2) if string.find(string1,string2) then return true else return false end end
  53.  
  54. function totalBeesCount()
  55.     local ti = int[1].getItemsInNetwork()
  56.     local ta = int[1].getAvailableItems()
  57.     local count = 0
  58.     for i in ipairs(ti) do
  59.         if isBee(ti[i]) then
  60.             count = count + ti[i].size
  61.         end
  62.     end
  63.     return count
  64. end
  65.  
  66. function removeUnnatural()
  67.     local ti = int[1].getItemsInNetwork()
  68.     local ta = int[1].getAvailableItems()
  69.     local totalExported = 0
  70.     for i in ipairs(ti) do
  71.         if isBee(ti[i]) and not isNatural(ti[i]) then
  72.             local toexport = ti[i].size
  73.             repeat
  74.                 local exported = const.trashInterface.exportItem(ta[i].fingerprint,const.trashSide,toexport)
  75.                 toexport = toexport - exported.size
  76.                 totalExported = totalExported + exported.size
  77.             until toexport == 0
  78.         end
  79.     end
  80.     io.write("removeUnnatural() - removed " .. totalExported .. " \n")
  81. end
  82.  
  83. function clearNetwork()
  84.     local ti = int[1].getItemsInNetwork()
  85.     local ta = int[1].getAvailableItems()
  86.     local totalExported = 0
  87.     for i in ipairs(ti) do
  88.         if isBee(ti[i]) then
  89.             local toexport = ti[i].size
  90.             repeat
  91.                 local exported = const.trashInterface.exportItem(ta[i].fingerprint,const.trashSide,toexport)
  92.                 toexport = toexport - exported.size
  93.                 totalExported = totalExported + exported.size
  94.             until toexport == 0
  95.         end
  96.     end
  97.     io.write("clearNetwork() - removed " .. totalExported .. " \n")
  98. end
  99.  
  100. function isApiaryFree(num)
  101.     for i = 1,9 do
  102.         if apiary[num].getStackInSlot(i) then
  103.             return false
  104.         end
  105.     end
  106.     return true
  107. end
  108.  
  109. function waitForApiary(num)
  110.    
  111.     io.write("waitForApiary(" .. num .. ") ")
  112.     if isApiaryFree(num) ~= true then
  113.         repeat
  114.             io.write(". ")
  115.             os.sleep(3)
  116.         until isApiaryFree(num) == true
  117.             io.write(" \n")
  118.     else
  119.         io.write("waitForApiary(" .. num .. ") - is free \n" )
  120.     end
  121. end
  122.  
  123. function waitForAnalyze()
  124.     local count1 = totalBeesCount()
  125.     local a = analyzeAll()
  126.     if a ~= false then
  127.         io.write("waitForAnalyze() - analyzing ")
  128.         repeat
  129.             io.write(" .")
  130.             os.sleep(5)
  131.         until totalBeesCount() == count1
  132.         io.write("\nwaitForAnalyze() - analysis finished\n")
  133.     else
  134.         io.write("waitForAnalyze() - nothing to analyze\n")
  135.     end
  136. end
  137.  
  138. function analyze(table) -- ta[i]
  139.     local toexport = const.analyzerInterface.getItemDetail(table.fingerprint).basic().qty
  140.     local sent = 0
  141.     repeat
  142.         local exported = const.analyzerInterface.exportItem(table.fingerprint,const.analyzerChestSide,toexport)
  143.         toexport = toexport - exported.size
  144.         sent = sent + exported.size
  145.     until toexport == 0
  146.     return sent
  147. end
  148.  
  149. function analyzeAll()
  150.     local ti = int[1].getItemsInNetwork()
  151.     local ta = int[1].getAvailableItems()
  152.     local unknownStacks = 0
  153.     local knownStacks = 0
  154.     local beesSent = 0
  155.     local knownBees = 0
  156.     for i in ipairs(ti) do
  157.         if isBee(ti[i]) then
  158.             if not isAnalyzed(ti[i]) then
  159.                 unknownStacks = unknownStacks + 1
  160.                 beesSent = beesSent + analyze(ta[i])
  161.             else
  162.                 knownStacks = knownStacks + 1
  163.                 knownBees = knownBees + ti[i].size
  164.             end
  165.         end
  166.     end
  167.     io.write("analyzeAll() - known: " .. knownBees .. " bees (" .. knownStacks .. " stacks), being analyzed: " .. beesSent .. " bees (" .. unknownStacks .. " stacks) \n")
  168.     if unknownStacks == 0 then
  169.         return false
  170.     end
  171. end
  172.  
  173. function isType(table,type) -- "drone" or "princess" or "queen"
  174.     if string.lower(type) == "drone" then
  175.         return isDrone(table)
  176.     elseif string.lower(type) == "princess" then
  177.         return isPrincess(table)
  178.     elseif string.lower(type) == "queen" then
  179.         return isQueen(table)
  180.     else
  181.         io.write("isType() - incorrect argument " .. tostring(type) .. " \n")
  182.     end
  183. end
  184.  
  185. function isPurity(table,purity)
  186.     if string.lower(purity) == "pure" then
  187.         return isPure(table)
  188.     elseif string.lower(purity) == "unpure" then
  189.         return isUnpure(table)
  190.     else
  191.         io.write("isPurity() - incorrect argument " .. tostring(purity) .. " \n")
  192.     end
  193. end
  194.  
  195. function countPrincess(al1,al2)
  196.     local ti = int[1].getItemsInNetwork()
  197.     local ta = int[1].getAvailableItems()
  198.     local count = 0
  199.     for i in ipairs(ti) do
  200.         if isBee(ti[i]) and isAnalyzed(ti[i]) and isPrincess(ti[i]) then
  201.             if al1check(ti[i],al1) and al2check(ti[i],al2) then
  202.                 count = count + ti[i].size
  203.             end
  204.         end
  205.     end
  206.     io.write("countPrincess() - " .. tostring(al1) .. "/" .. tostring(al2) .. " - " .. count .. "\n")
  207.     return count
  208. end
  209.  
  210. function countDrone(al1,al2)
  211.     local ti = int[1].getItemsInNetwork()
  212.     local ta = int[1].getAvailableItems()
  213.     local count = 0
  214.     for i in ipairs(ti) do
  215.         if isBee(ti[i]) and isAnalyzed(ti[i]) and isDrone(ti[i]) then
  216.             if al1check(ti[i],al1) and al2check(ti[i],al2) then
  217.                 count = count + ti[i].size
  218.             end
  219.         end
  220.     end
  221.     io.write("countDrone() - " .. tostring(al1) .. "/" .. tostring(al2) .. " - " .. count .. "\n")
  222.     return count
  223. end
  224.  
  225.  
  226.  
  227. function al1check(table,al1)
  228.     if al1 then
  229.         if string.lower(al1) == string.lower(table.individual.active.species) then
  230.             return true
  231.         else
  232.             return false
  233.         end
  234.     else
  235.         return true
  236.     end
  237. end
  238.  
  239. function al2check(table,al2)
  240.     if al2 then
  241.         if string.lower(al2) == string.lower(table.individual.inactive.species) then
  242.             return true
  243.         else
  244.             return false
  245.         end
  246.     else
  247.         return true
  248.     end
  249. end
  250.  
  251.  
  252. function move(interface,side,table,number) -- table = ta[i] ONLY
  253.     local toexport = math.min(number or 1,table.size)
  254.     local totalExported = 0
  255.     repeat
  256.         local exported = int[interface].exportItem(table.fingerprint,side,toexport)
  257.         toexport = toexport - exported.size
  258.         totalExported = totalExported + exported.size
  259.     until toexport == 0
  260.     io.write("move() - moved:" .. totalExported .. ", int:" .. interface .. ", side:" .. side .. ", " .. table.fingerprint.id .. ":" .. table.fingerprint.dmg .. " \n")
  261.     return totalExported
  262. end
  263.  
  264. function house1(table)
  265.     move(1,const.houseSide,table,1)
  266. end
  267.  
  268. function getParents(spec)
  269.     if string.lower(spec) == "common" then
  270.         return "forest","meadows"
  271.     elseif string.lower(spec) == "cultivated" then
  272.         return "common","forest"
  273.     else
  274.         local t = apiary[1].getBeeParents(spec)
  275.         local par1 = t[1].allele1.name
  276.         local par2 = t[1].allele2.name
  277.         return par1, par2
  278.     end
  279. end
  280.  
  281. function GET(purity,type,spec) -- RETURNS ta[i], ("pure","princess","common") or ("unpure","drone","meadows"), pure means al1 == al2
  282.     local ti = int[1].getItemsInNetwork()
  283.     local ta = int[1].getAvailableItems()
  284.     local count = 0
  285.     local tai
  286.     local speed = 0
  287.     for i in ipairs(ti) do
  288.         if isBee(ti[i]) and isAnalyzed(ti[i]) then
  289.             if isType(ti[i],type) and isPurity(ti[i],purity) and isAlx(ti[i],spec) then
  290.                 count = count + ti[i].size
  291.                 if ti[i].individual.active.speed + ti[i].individual.inactive.speed > speed then
  292.                     speed = ti[i].individual.active.speed + ti[i].individual.inactive.speed
  293.                     tai = ta[i]
  294.                 end
  295.             end
  296.         end
  297.     end
  298.     io.write("GET() - " .. purity .. " " .. type .. " " .. spec .. " - found " .. count .. " (returned avg speed: " .. speed/2 .. ") \n")
  299.     return count, tai
  300. end
  301.  
  302. function GET1(type,spec1,spec2) -- RETURNS ta[i], gets only bees with BOTH spec genes present
  303.     local ti = int[1].getItemsInNetwork()
  304.     local ta = int[1].getAvailableItems()
  305.     local count = 0
  306.     local tai
  307.     local speed = 0
  308.     for i in ipairs(ti) do
  309.         if isBee(ti[i]) and isAnalyzed(ti[i]) then
  310.             if isType(ti[i],type) and isAlx(ti[i],spec1) and isAlx(ti[i],spec2) then
  311.                 count = count + ti[i].size
  312.                 if ti[i].individual.active.speed + ti[i].individual.inactive.speed > speed then
  313.                     speed = ti[i].individual.active.speed + ti[i].individual.inactive.speed
  314.                     tai = ta[i]
  315.                 end
  316.             end
  317.         end
  318.     end
  319.     io.write("GET1() - " .. type .. " " .. spec1 .. "+" .. spec2 .. " - found " .. count .. " (returned avg speed: " .. speed/2 .. ") \n")
  320.     return count, tai
  321. end
  322.  
  323. function GET3(type,spec) -- RETURNS ta[i], counts bees of TYPE and at least 1 of genes SPEC
  324.     local ti = int[1].getItemsInNetwork()
  325.     local ta = int[1].getAvailableItems()
  326.     local count = 0
  327.     local tai
  328.     local speed = 0
  329.     for i in ipairs(ti) do
  330.         if isBee(ti[i]) and isAnalyzed(ti[i]) then
  331.             if isType(ti[i],type) and isAlx(ti[i],spec) then
  332.                 count = count + ti[i].size
  333.                 if ti[i].individual.active.speed + ti[i].individual.inactive.speed > speed then
  334.                     speed = ti[i].individual.active.speed + ti[i].individual.inactive.speed
  335.                     tai = ta[i]
  336.                 end
  337.             end
  338.         end
  339.     end
  340.     io.write("GET3() - found " .. count .. " " .. spec .. " " .. type .. " \n")
  341.     return count, tai
  342. end
  343.  
  344. function GET4(purity,type) -- RETURNS ta[i],
  345.     local ti = int[1].getItemsInNetwork()
  346.     local ta = int[1].getAvailableItems()
  347.     local count = 0
  348.     local tai
  349.     local speed = 0
  350.     local reportedSpecs
  351.     for i in ipairs(ti) do
  352.         if isBee(ti[i]) and isAnalyzed(ti[i]) then
  353.             if isType(ti[i],type) and isPurity(ti[i],purity) then
  354.                 count = count + ti[i].size
  355.                 if ti[i].individual.active.speed + ti[i].individual.inactive.speed > speed then
  356.                     speed = ti[i].individual.active.speed + ti[i].individual.inactive.speed
  357.                     reportedSpecs = ti[i].individual.active.species .. "/" .. ti[i].individual.inactive.species
  358.                     tai = ta[i]
  359.                 end
  360.             end
  361.         end
  362.     end
  363.     io.write("GET4() - " .. purity .. " " .. type .. " - found " .. tostring(reportedSpecs) .. " " .. count .. " (returned avg speed: " .. speed/2 .. ") \n")
  364.     return count, tai
  365. end
  366.  
  367. function breed(spec)
  368.     local par1, par2 = getParents(spec)
  369.     local princess = nil
  370.     local drone = nil
  371.     local function getDrone(num) -- num is 1 for par1, 2 for par2, 3 for par1 AND par2
  372.         if num == 2 then
  373.             if GET("pure","drone",par2) > 0 then
  374.                 _,drone = GET("pure","drone",par2)
  375.             elseif GET1("drone",par1,par2) > 0 then
  376.                     _,drone = GET1("drone",par1,par2)
  377.             elseif GET("unpure","drone",par2) > 0 then
  378.                 _,drone = GET("unpure","drone",par2)
  379.             end
  380.         elseif num == 1 then
  381.             if GET("pure","drone",par1) > 0 then
  382.                 _,drone = GET("pure","drone",par1)
  383.             elseif GET1("drone",par1,par2) > 0 then
  384.                 _,drone = GET1("drone",par1,par2)
  385.             elseif GET("unpure","drone",par1) > 0 then
  386.                 _,drone = GET("unpure","drone",par1)
  387.             end
  388.         elseif num == 3 then
  389.             if GET1("drone",par1,par2) > 0 then
  390.                 _,drone = GET1("drone",par1,par2)
  391.             elseif GET("pure","drone",par1) > 0 then
  392.                 _,drone = GET("pure","drone",par1)
  393.             elseif GET("pure","drone",par2) > 0 then
  394.                 _,drone = GET("pure","drone",par2)
  395.             elseif GET("unpure","drone",par1) > 0 then
  396.                 _,drone = GET("unpure","drone",par1)
  397.             elseif GET("unpure","drone",par2) > 0 then
  398.                 _,drone = GET("unpure","drone",par2)
  399.             end
  400.         end
  401.     end
  402.     if not isStrong(par1) and par1 ~= "forest" and par1 ~= "meadows" then
  403.         io.write("breed() - " .. par1 .. " is not Strong, calling multiply() for ".. par1 .. " \n")
  404.         multiply(par1)
  405.         return true
  406.     elseif not isStrong(par2) and par1 ~= "forest" and par1 ~= "meadows" then
  407.         io.write("breed() - " .. par2 .. " is not Strong, calling multiply() for ".. par2 .. " \n")
  408.         multiply(par2)
  409.         return true
  410.     end
  411.     if GET("pure","princess",par1) > 2 then
  412.         _,princess = GET("pure","princess",par1)
  413.         getDrone(2)
  414.     end
  415.  
  416.     if drone == nil then
  417.         if GET("pure","princess",par2) > 2 then
  418.             _,princess = GET("pure","princess",par2)
  419.             getDrone(1)
  420.         end
  421.     end
  422.  
  423.     if drone == nil then
  424.         if GET1("princess",par1,par2) > 0 then
  425.             _,princess = GET1("princess",par1,par2)
  426.             getDrone(3)
  427.         end
  428.     end
  429.  
  430.     if drone == nil then
  431.         if GET("unpure","princess",par1) > 0 then
  432.             _,princess = GET("unpure","princess",par1)
  433.             getDrone(2)
  434.         end
  435.     end
  436.  
  437.     if drone == nil then
  438.         if GET("unpure","princess",par2) > 0 then
  439.             _,princess = GET("unpure","princess",par2)
  440.             getDrone(1)
  441.         end
  442.     end
  443.  
  444.     if princess and drone then
  445.         io.write("breed(".. spec ..") - housing \n")
  446.         house1(princess)
  447.         house1(drone)
  448.     else
  449.         local missingSpecGene = nil
  450.         local isPrincessMissing = nil
  451.         local isDroneMissing = nil
  452.         io.write("breed() - cant find (enough) princesses OR a drone to breed " .. spec .. " \n")
  453.         if GET3("drone",par1) < 1 then
  454.             io.write("breed(".. spec ..") - missing drone with at least 1 gene of spec " .. par1 .. " \n")
  455.             missingSpecGene = par1
  456.             isDroneMissing = true
  457.         end
  458.         if  GET3("drone",par2) < 1 then
  459.             io.write("breed(".. spec ..") - missing drone with at least 1 gene of spec " .. par2 .. " \n")
  460.             if missingSpecGene == nil then
  461.                 missingSpecGene = par2
  462.             end
  463.             isDroneMissing = true
  464.         end
  465.         if GET3("princess",par1) < 3 then
  466.             io.write("breed(".. spec ..") - missing princess (or not enough pures) with at least 1 gene of spec " .. par1 .. " \n")
  467.             if missingSpecGene == nil then
  468.                 missingSpecGene = par1
  469.             end
  470.             isPrincessMissing = true
  471.         end
  472.         if  GET3("drone",par2) < 3 then
  473.             io.write("breed(".. spec ..") - missing princess (or not enough pures) with at least 1 gene of spec " .. par2 .. " \n")
  474.             if missingSpecGene == nil then
  475.                 missingSpecGene = par2
  476.             end
  477.             isPrincessMissing = true
  478.         end
  479.         gpu.setForeground(0x00FF00)
  480.         io.write("breed(".. spec ..") - calling multiply for species " .. missingSpecGene .. " \n")
  481.         gpu.setForeground(0xFFFFFF)
  482.         multiply(missingSpecGene)
  483.     end
  484. end
  485.  
  486.  
  487.  
  488. function isStrong(spec)
  489.     if GET("pure","princess",spec) >= const.strongPrincessCount and GET("pure","drone",spec) >= const.strongCount then
  490.         return true
  491.     else
  492.         return false
  493.     end
  494. end
  495.  
  496.  
  497.  
  498. function multiply(spec)
  499.     local princess = nil
  500.     local drone = nil
  501.  
  502.     local function getPrincessAndDrone()
  503.         if GET("pure","princess",spec) > 0 then
  504.             _,princess = GET("pure","princess",spec)
  505.         else
  506.             if
  507.                 GET("unpure","princess",spec) > 0 then
  508.                 _,princess = GET("unpure","princess",spec)
  509.             end
  510.         end
  511.  
  512.         if GET("pure","drone",spec) > 0 then
  513.             _,drone = GET("pure","drone",spec)
  514.         else
  515.             if
  516.                 GET("unpure","drone",spec) > 0 then
  517.                 _,drone = GET("unpure","drone",spec)
  518.             end
  519.         end
  520.     end
  521.  
  522.     local function makePrincess()
  523.         local princess1 = nil
  524.         local drone1 = nil
  525.         if GET("unpure","princess",spec) > 0 then
  526.             _,princess1 = GET("unpure","princess",spec)
  527.         elseif GET4("unpure","princess") > 0 then
  528.             _,princess1 =  GET4("unpure","princess")
  529.         elseif GET("pure","princess","rocky") > 0 then
  530.             _,princess1 = GET("pure","princess","rocky")
  531.         else
  532.             gpu.setForeground(0x00FF00)
  533.             io.write("makePrincess() - ERROR#2 - no princesses with Rocky gene available \n")
  534.             gpu.setForeground(0xFFFFFF)
  535.             error("ERROR#2")
  536.         end
  537.         _,drone1 = GET("pure","drone",spec)
  538.         house1(princess1)
  539.         house1(drone1)
  540.     end
  541.     if isStrong(spec) then
  542.         gpu.setForeground(0x00FF00)
  543.         io.write("multiply() - called to multiply " .. spec .. " - strong species (" .. const.strongCount .. " drones and ".. const.strongPrincessCount .. " pure princesses) achieved! \n")
  544.         gpu.setForeground(0xFFFFFF)
  545.     else
  546.         getPrincessAndDrone()
  547.         if princess and drone then
  548.             if GET("pure","princess",spec) < const.strongPrincessCount and GET("pure","drone",spec) >= const.strongCount then
  549.                 gpu.setForeground(0x00FF00)
  550.                 io.write("multiply() - found <" .. const.strongPrincessCount .. " pure princesses of " .. spec .. " and >=" .. const.strongCount .." drones, calling makePrincess() " .. spec .. " \n")
  551.                 gpu.setForeground(0xFFFFFF)
  552.                 makePrincess()
  553.             elseif GET("pure","princess",spec) > 0 and GET("pure","drone",spec) < const.strongCount then
  554.                 gpu.setForeground(0xff9933)
  555.                 io.write("multiply() - forming strong specie of " .. spec .. " \n")
  556.                 gpu.setForeground(0xFFFFFF)
  557.                
  558.                 house1(princess)
  559.                 house1(drone)
  560.             else   
  561.                 gpu.setForeground(0x00FF00)
  562.                 io.write("multiply() - attempting to multiply specie of " .. spec .. " \n")
  563.                 gpu.setForeground(0xFFFFFF)
  564.                
  565.                 house1(princess)
  566.                 house1(drone)
  567.             end
  568.         elseif not princess and not drone then
  569.             io.write("multiply() - cant find princess NOR drone of species " .. spec .. " \n")
  570.             gpu.setForeground(0x00FF00)
  571.             io.write("multiply() - calling breed() " .. spec .. " \n")
  572.             gpu.setForeground(0xFFFFFF)
  573.             breed(spec)
  574.         elseif princess == nil and GET("pure","drone",spec) > 0 then
  575.             io.write("multiply() - cant find princess (have pure drone) of species " .. spec .. " \n")
  576.             gpu.setForeground(0x00FF00)
  577.             io.write("multiply() - calling makePrincess() " .. spec .. " \n")
  578.             gpu.setForeground(0xFFFFFF)
  579.             makePrincess()
  580.         else
  581.             io.write("multiply() - cant find princess AND drone of species " .. spec .. " \n")
  582.             gpu.setForeground(0x00FF00)
  583.             io.write("multiply() - calling breed() " .. spec .. " \n")
  584.             gpu.setForeground(0xFFFFFF)
  585.             breed(spec)
  586.         end
  587.     end
  588. end
  589.  
  590.  
  591. function houseBee(interface,type,al1,al2)
  592.     local ti = int[interface].getItemsInNetwork()
  593.     local ta = int[interface].getAvailableItems()
  594.     for i in ipairs(ti) do
  595.         if isBee(ti[i]) and isAnalyzed(ti[i]) and isType(ti[i],type) then
  596.             if al1check(ti[i],al1) and al2check(ti[i],al2) then
  597.                 house1(ta[i])
  598.                 io.write("houseBee() - " .. tostring(al1) .. "/" .. tostring(al2) .. " " .. tostring(type) .. " housed \n")
  599.                 return true
  600.             end
  601.         end
  602.     end
  603.     io.write("houseBee() - nothing found \n")
  604. end
  605.  
  606. function console()
  607.     while true do
  608.         gpu.setForeground(0x00FF00)
  609.         io.write("Console >> ")
  610.         gpu.setForeground(0x99ccff)
  611.         local command = io.read()
  612.         gpu.setForeground(0xFFFFFF)
  613.         if command == "close" then
  614.             return true
  615.         else
  616.             local a,err = pcall((load(command)))
  617.             if a == false then
  618.                 gpu.setForeground(0xFF0000)
  619.                 io.write("failed: ")
  620.                 gpu.setForeground(0xFFFFFF)
  621.                 io.write(tostring(err))
  622.             else
  623.                 io.write("success ")
  624.             end
  625.             io.write("\n")
  626.         end
  627.     end
  628. end
  629.  
  630. function achieve(spec)
  631.     while true do
  632.         removeUnnatural()
  633.         if isStrong(spec) then
  634.             break
  635.         else
  636.             waitForAnalyze()
  637.             multiply(spec)
  638.             waitForApiary(1)
  639.         end
  640.     end
  641. end
  642.  
  643. --
  644. term.clear()
  645. removeUnnatural()
  646. console()
Add Comment
Please, Sign In to add comment