Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chest = peripheral.wrap("left")
- apiary = peripheral.wrap("powered_tile_1")
- function getBees()
- local drones={}
- local princesses={}
- for id,data in pairs(chest.getAllStacks()) do
- local name=string.lower(data.select().display_name)
- if string.match(name,"drone")~=nil then
- drones[ string.gsub(name," drone","") ] = true
- elseif string.match(name,"princess")~=nil then
- princesses[ string.gsub(name," princess","") ] = true
- end
- end
- return drones,princesses
- end
- function hasDrone(name)
- local drones=getBees()
- if drones[name]==true then
- return true
- end
- return false
- end
- function hasPrincess(name)
- local _,princs=getBees()
- if princs[name]==true then
- return true
- end
- return false
- end
- function getSlot(target)
- for id,data in pairs(chest.getAllStacks()) do
- local name=string.lower(data.select().display_name)
- if name==target then
- return id
- end
- end
- return false
- end
- function convert(array)
- local comboTable={}
- for id,combo in pairs(array) do
- comboTable[id]={
- combo.allele1.name,
- combo.allele2.name,
- }
- end
- return comboTable
- end
- function startBreed(drone,princ)
- local pSlot=getSlot(princ.." princess")
- local dSlot=getSlot(drone.." drone")
- if chest.pushItem("south",pSlot,1,1)~=1 then return false end
- chest.pushItem("south",dSlot,1,2)
- end
- function tryBreed(targetBee)
- local combos=convert(apiary.getBeeParents(targetBee))
- for i,combo in pairs( breeds[targetBee] ) do
- if hasDrone(combo[1])==true and hasPrincess(combo[2])==true then
- if startBreed(combo[1],combo[2])==false then break end
- print(combo[1].."+"..combo[2].."="..targetBee)
- break
- elseif hasDrone(combo[2])==true and hasPrincess(combo[1])==true then
- if startBreed(combo[2],combo[1])==false then break end
- print(combo[2].."+"..combo[1].."="..targetBee)
- break
- end
- end
- end
- function breed(bee)
- while true do
- if getSlot("noble princess")==true then
- return true
- end
- tryBreed("noble")
- sleep(5)
- end
- end
- breed(target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement