forestry/forestry_bees/mutations.lua
2024-10-07 19:52:09 +02:00

37 lines
1.7 KiB
Lua

forestry_bees.bee_mutations = {}
local function register_mutation(bee_type_in1,bee_type_in2,bee_type_out,chance)
--bee_type_in are string of the gene ex. "forest" or "meadows"
--bee_type_out is a string of the gene
--chance is the base probability of the mutation
--the function appends in the table at position "bee_type_in1","bee_type_in2"
--of the matrix forestry_bees.mutations "bee_type_out"=chance
--and does so simmetrically
--populate table if nil
if forestry_bees.bee_mutations[bee_type_in1] == nil or not next(forestry_bees.bee_mutations[bee_type_in1]) then
forestry_bees.bee_mutations[bee_type_in1] = {}
end
if forestry_bees.bee_mutations[bee_type_in2] == nil or not next(forestry_bees.bee_mutations[bee_type_in2]) then
forestry_bees.bee_mutations[bee_type_in2] = {}
end
if forestry_bees.bee_mutations[bee_type_in1][bee_type_in2] == nil or not next(forestry_bees.bee_mutations[bee_type_in1][bee_type_in2]) then
forestry_bees.bee_mutations[bee_type_in1][bee_type_in2] = {}
end
if forestry_bees.bee_mutations[bee_type_in2][bee_type_in1] == nil or not next(forestry_bees.bee_mutations[bee_type_in2][bee_type_in1]) then
forestry_bees.bee_mutations[bee_type_in2][bee_type_in1] = {}
end
forestry_bees.bee_mutations[bee_type_in1][bee_type_in2][bee_type_out] = chance
forestry_bees.bee_mutations[bee_type_in2][bee_type_in1][bee_type_out] = chance
end
register_mutation("forest","meadow","common",0.15)
register_mutation("forest","common","cultivated",0.12)
register_mutation("meadow","common","cultivated",0.12)
register_mutation("common","cultivated","noble",0.10)
register_mutation("common","cultivated","diligent",0.10)
--print(forestry_bees.mutations["meadows"]["forest"]["common"])