forestry/forestry_bees/mutations.lua

62 lines
2.5 KiB
Lua
Raw Permalink Normal View History

2024-10-07 19:52:09 +02:00
forestry_bees.bee_mutations = {}
local function fun_true(pos) return true end
local function check_biome(biome)
return function(pos)
return (minetest.get_biome_name(minetest.get_biome_data(pos)["biome"]) == biome)
end
end
local function register_mutation(bee_type_in1,bee_type_in2,bee_type_out,chance,check_fun)
2024-10-07 19:52:09 +02:00
--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 = chance, check_fun = check_fun}
forestry_bees.bee_mutations[bee_type_in2][bee_type_in1][bee_type_out] = {chance = chance, check_fun = check_fun}
2024-10-07 19:52:09 +02:00
end
2024-10-10 16:18:11 +02:00
--common branch
register_mutation("forest","meadows","common",0.15,fun_true)
register_mutation("forest","common","cultivated",0.12,fun_true)
register_mutation("meadows","common","cultivated",0.12,fun_true)
2024-10-10 16:18:11 +02:00
--noble branch
register_mutation("common","cultivated","noble",0.10,fun_true)
register_mutation("noble","cultivated","majestic",0.08,fun_true)
register_mutation("noble","majestic","imperial",0.08,fun_true)
2024-10-10 16:18:11 +02:00
--industrious branch
register_mutation("common","cultivated","diligent",0.10,fun_true)
register_mutation("diligent","cultivated","unweary",0.08,fun_true)
register_mutation("diligent","unweary","industrious",0.08,fun_true)
2024-10-10 16:18:11 +02:00
---heroic branch
---infernal branch
--- austere branch
---end branch
---tropical branch
---frozen branch
---festive branch
--agrarian branch
register_mutation("diligent","meadows","rural",0.12,check_biome("grassland"))
2024-10-10 16:18:11 +02:00
2024-10-07 19:52:09 +02:00
--print(forestry_bees.mutations["meadows"]["forest"]["common"])