From 2769aa978e3c08e433b64828adc32f3998830195 Mon Sep 17 00:00:00 2001 From: StochasticMouse Date: Wed, 9 Oct 2024 15:12:16 +0200 Subject: [PATCH] added base_genes to bee_types and now genes get printed on bee usage --- forestry_bees/bee_genes.lua | 31 +++++++++++++++++++++++++++++++ forestry_bees/init.lua | 1 + forestry_bees/register.lua | 11 ++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 forestry_bees/bee_genes.lua diff --git a/forestry_bees/bee_genes.lua b/forestry_bees/bee_genes.lua new file mode 100644 index 0000000..177457d --- /dev/null +++ b/forestry_bees/bee_genes.lua @@ -0,0 +1,31 @@ +forestry_bees.bee_base_genes = {} + +local function register_base_gene(bee_type, base_genes) + forestry_bees.bee_base_genes[bee_type] = base_genes +end + +function forestry_bees.return_all_genes_double(bee_type) + local output = {type_gene = {bee_type, bee_type}} + for key,value in pairs(forestry_bees.bee_base_genes[bee_type]) do + output[key] = {value, value} + end + return output +end + +function forestry_bees.return_all_genes(bee_type) + local output = {type_gene = bee_type} + for key,value in pairs(forestry_bees.bee_base_genes[bee_type]) do + output[key] = value + end + return output +end + +function forestry_bees.return_genes(bee_type) + return forestry_bees.bee_base_genes[bee_type] +end +register_base_gene("forest",{fertility = 3, lifespan = 10}) +register_base_gene("meadow",{fertility = 2, lifespan = 10}) +register_base_gene("common",{fertility = 2, lifespan = 10}) +register_base_gene("cultivated",{fertility = 2, lifespan = 10}) +register_base_gene("noble",{fertility = 2, lifespan = 30}) +register_base_gene("diligent",{fertility = 2, lifespan = 30}) \ No newline at end of file diff --git a/forestry_bees/init.lua b/forestry_bees/init.lua index f1921e3..696789b 100644 --- a/forestry_bees/init.lua +++ b/forestry_bees/init.lua @@ -3,6 +3,7 @@ forestry_bees = {} forestry_bees.settings = Settings(minetest.get_modpath("forestry_bees") .. "/forestry_bees.conf") dofile(minetest.get_modpath("forestry_bees") .. "/helper.lua") +dofile(minetest.get_modpath("forestry_bees") .. "/bee_genes.lua") dofile(minetest.get_modpath("forestry_bees") .. "/register.lua") dofile(minetest.get_modpath("forestry_bees") .. "/bee_drops.lua") dofile(minetest.get_modpath("forestry_bees") .. "/mutations.lua") diff --git a/forestry_bees/register.lua b/forestry_bees/register.lua index b849dc2..a6495f0 100644 --- a/forestry_bees/register.lua +++ b/forestry_bees/register.lua @@ -9,7 +9,8 @@ end local function printbeestats(itemstack, user, pointed_thing) local meta = itemstack:get_meta() local name = itemstack:get_name() - minetest.chat_send_player(user:get_player_name(), "Name:"..string.sub(string.match(name, ":.*"),2)..", Active:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][1]..", Inactive:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][2]) + minetest.chat_send_player(user:get_player_name(), "Name: "..string.sub(string.match(name, ":.*"),2).."\nGenes:"..string.gsub(meta:get_string("genes"), "return", "") ) + --minetest.chat_send_player(user:get_player_name(), "Name:"..string.sub(string.match(name, ":.*"),2)..", Active:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][1]..", Inactive:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][2]) end local function register_bee(name, color1, color2) @@ -55,8 +56,8 @@ minetest.register_node("forestry_bees:forest_beehive", { drop = { max_items = 3, items = { - {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", {type_gene = {"forest","forest"}, fertility = {2,2}, lifespan = {10,10}})}}, - {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", {type_gene = {"forest","forest"}, fertility = {2,2}, lifespan = {10,10}})}}, + {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("forest"))}}, + {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("forest"))}}, {tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:honey_comb"}} } } @@ -77,8 +78,8 @@ minetest.register_node("forestry_bees:meadow_beehive", { drop = { max_items = 3, items = { - {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", {type_gene = {"meadow","meadow"}, fertility = {3,3}, lifespan = {10,10} })}}, - {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", {type_gene = {"meadow","meadow"}, fertility = {3,3}, lifespan = {10,10}})}}, + {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("meadow"))}}, + {tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("meadow"))}}, {tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:honey_comb"}} } }