Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onlyAnalyzedBees=false
- genomeBuffer=2
- delay=5
- function wrapPs(peripheralName)
- periTab = {}
- sideTab = {}
- if peripheralName == nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i = 1, #peripherals do
- if peripheral.getType(peripherals[i]) == peripheralName then
- periTab[i2] = peripheral.wrap(peripherals[i])
- sideTab[i2] = peripherals[i]
- i2 = i2 + 1
- end
- end
- if periTab ~= {} then
- return periTab, sideTab
- else
- return nil
- end
- function getPSide(peripheralName)
- if peripheralName == nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i = 1
- while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
- i = i + 1
- end
- if peripheral.getType(peripherals[i]) == peripheralName then
- return peripherals[i]
- else
- return nil
- end
- end
- end
- me = wrapPs("appliedenergistics2:interface")[1]
- smplr = wrapPs("gendustry:sampler")[1]
- attrIndex = {"Species","Effect","Speed","Flowering","Flowers"}
- function getBeeData()
- bee=nil
- if (smplr.getItem(3)~=nil) then
- bee=smplr.getItem(3).getMetadata()
- end
- if bee~=nil then
- beeData={}
- beeData.active={}
- beeData.inactive={}
- beeData.active["Species"]=bee.individual.genome.active.species.displayName
- beeData.inactive["Species"]=bee.individual.genome.inactive.species.displayName
- end
- return beeData
- end
- function getSample(sample)
- smpl={}
- smpl.name=sample.getMetadata().displayName
- smpl.trade=string.sub(smpl.name,14,string.find(smpl.name,":")-1)
- smpl.val=string.sub(smpl.name,string.find(smpl.name,":")+2)
- return smpl
- end
- function getSamples()
- smpls=me.findItems("gendustry:gene_sample")
- smplsData={}
- for i=1,#smpls do
- table.insert(smplsData,getSample(smpls[i]))
- end
- return smplsData
- end
- function beeFinished()
- beeIsFinished=false
- smplsData=getSamples()
- beeData=getBeeData()
- if beeData ~=nil then
- for i=1,#smplsData do
- if smplsData[i].trade=="Species" then
- if beeData.active.Species==smplsData[i].val then
- beeIsFinished=true
- end
- if beeData.inactive.Species==smplsData[i].val then
- beeIsFinished=true
- end
- end
- end
- end
- return beeIsFinished
- end
- function dumpOverdueSamples()
- smpls=me.findItems("gendustry:gene_sample")
- for i=1,#smpls do
- if smpls[i].getMetadata().count>genomeBuffer then
- smpls[i].export("up",1)
- end
- end
- end
- function main()
- while true do
- dumpOverdueSamples()
- if beeFinished() then
- smplr.pushItems("up",3)
- end
- end
- sleep(delay)
- end
- main()
Add Comment
Please, Sign In to add comment