Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ender = peripheral.wrap("bottom")
- dronesCab = peripheral.wrap("right")
- princessesCab = peripheral.wrap("left")
- local receiveFrequency={colors.pink,colors.magenta,colors.cyan}
- local sendFrequency={colors.purple,colors.magenta,colors.cyan}
- local apiarys={
- {apiary="powered_tile_2",chest="ender_chest_0",direction="east",counterDirection="west",},
- {apiary="powered_tile_3",chest="ender_chest_1",direction="east",counterDirection="west",},
- {apiary="powered_tile_4",chest="ender_chest_2",direction="east",counterDirection="west",},
- {apiary="powered_tile_5",chest="ender_chest_5",direction="west",counterDirection="east",},
- {apiary="powered_tile_6",chest="ender_chest_4",direction="west",counterDirection="east",},
- {apiary="powered_tile_7",chest="ender_chest_3",direction="west",counterDirection="east",},
- }
- for id,data in pairs(apiarys) do
- apiarys[id]={apiary=peripheral.wrap(data.apiary),chest=peripheral.wrap(data.chest),direction=data.direction,counterDirection=data.counterDirection}
- end
- function getDrones()
- local drones={}
- for id,data in pairs(dronesCab.getAllStacks()) do
- local name=string.lower(data.select().display_name)
- if string.match(name,"drone")~=nil then
- drones[ string.gsub(name," drone","") ] = true
- drones[ name ] = true
- end
- end
- return drones
- end
- function getPrincesses()
- local princesses={}
- for id,data in pairs(princessesCab.getAllStacks()) do
- local name=string.lower(data.select().display_name)
- if string.match(name,"princess")~=nil then
- princesses[ string.gsub(name," princess","") ] = true
- princesses[ name ] = true
- end
- end
- return princesses
- end
- function hasDrone(name)
- local drones=getDrones()
- if drones[name]==true then
- return true
- end
- return false
- end
- function hasPrincess(name)
- local princesses=getPrincesses()
- if princesses[name]==true then
- return true
- end
- return false
- end
- function getDroneSlot(target)
- if hasDrone(target)==false then return false end
- for id,data in pairs(dronesCab.getAllStacks()) do
- local name=string.lower(data.select().display_name)
- if name==target then
- return id
- end
- end
- return false
- end
- function getPrincessSlot(target)
- if hasPrincess(target)==false then return false end
- for id,data in pairs(princessesCab.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]={
- string.lower(combo.allele1.name),
- string.lower(combo.allele2.name),
- }
- end
- return comboTable
- end
- function startBreed(drone,princess)
- local pSlot=getPrincessSlot(princess.." princess")
- local dSlot=getDroneSlot(drone.." drone")
- ender.setColors(sendFrequency[1],sendFrequency[2],sendFrequency[3])
- princessesCab.pushItem("down",pSlot,1,1)
- sleep(1)
- dronesCab.pushItem("down",dSlot,1,1)
- sleep(6)
- local sorted=false
- while sorted==false do
- print("Checking apiaries for empty spots")
- for id,apiary in pairs(apiarys) do
- apiary.chest.setColors(sendFrequency[1],sendFrequency[2],sendFrequency[3])
- sleep(0.5)
- if apiary.chest.pushItem(apiary.direction,1,1,1)==1 then
- apiary.chest.pushItem(apiary.direction,2,1,2)
- sorted=true
- apiarys[id].breeding=drone.." drone + "..princess.." princess"
- elseif apiary.chest.pushItem(apiary.direction,2,1,1)==1 then
- apiary.chest.pushItem(apiary.direction,1,1,2)
- sorted=true
- apiarys[id].breeding=drone.." drone + "..princess.." princess"
- end
- apiary.chest.setColors(receiveFrequency[1],receiveFrequency[2],receiveFrequency[3])
- end
- if sorted==false then
- print("None found")
- sleep(5)
- end
- end
- return true
- end
- function emptyApiaries()
- for id,apiary in pairs(apiarys) do
- apiary.chest.setColors(receiveFrequency[1],receiveFrequency[2],receiveFrequency[3])
- sleep(0.1)
- for i=7,15 do
- apiary.apiary.pushItem(apiary.counterDirection,i,10,i)
- end
- end
- end
- function tryBreed(targetBee)
- term.clear()
- term.setCursorPos(1,1)
- print("Attempting to breed a "..targetBee.." bee")
- local attempts
- local combos=convert(apiarys[1].apiary.getBeeParents(targetBee))
- for i,combo in pairs( combos ) do
- --print("Possible combo: "..combo[1].."+"..combo[2])
- if hasDrone(combo[1])==true and hasPrincess(combo[2])==true then
- print(combo[1].." + "..combo[2].." = "..targetBee)
- if startBreed(combo[1],combo[2])==false then break end
- return
- elseif hasDrone(combo[2])==true and hasPrincess(combo[1])==true then
- print(combo[2].." + "..combo[1].." = "..targetBee)
- if startBreed(combo[2],combo[1])==false then break end
- return
- end
- if debugmode==true then
- if hasDrone(combo[1])==true then
- print("Possible combo requires a "..combo[2].." princess")
- elseif hasDrone(combo[2])==true then
- print("Possible combo requires a "..combo[1].." princess")
- elseif hasPrincess(combo[1])==true then
- print("Possible combo requires a "..combo[1].." drone")
- elseif hasPrincess(combo[2])==true then
- print("Possible combo requires a "..combo[1].." drone")
- end
- end
- end
- print("No combos found, please supply more bees.")
- end
- function breed(bee)
- while true do
- if hasPrincess(bee.." princess")==true then
- return true
- end
- tryBreed(bee)
- emptyApiaries()
- sleep(5)
- end
- end
- function getTarget()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Target bee: ")
- local target=read()
- breed(target)
- end
- getTarget()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement