diff --git a/forestry_bees/apiary.lua b/forestry_bees/apiary.lua index 4c0de88..9b5869d 100644 --- a/forestry_bees/apiary.lua +++ b/forestry_bees/apiary.lua @@ -121,14 +121,6 @@ local function apiary_node_timer(pos,elapsed) can_live = is_queen --these two event are disjoint (there are no queen & princess) actionable = can_breed or can_live - - --if can_breed then -- adjust el to action duration - -- el = math.min(el, breedtime - src_time) - --end - --if can_live then -- adjust el to action duration - -- el = math.min(el, lifetime - src_time) - --end - local el = elapsed --if actionable check if things are ready if actionable then @@ -137,6 +129,15 @@ local function apiary_node_timer(pos,elapsed) el = math.min(el, needed_time - src_time) src_time = src_time + el + if can_live then --chance to drop honeycomb + local drops = forestry_bees.calculate_drop(monarchlist[1]:get_meta():get_string("active_gene")) + if (not (next(drops) == nil)) and inv:get_size("dst") - forestry_bees.stacks_in_inv(inv,"dst") >= #drops then + for _,drop in pairs(drops) do + inv:add_item("dst",drop) + end + end + end + if src_time >= needed_time then --if possible act accordingly to breed or live if can_breed then diff --git a/forestry_bees/bee_drops.lua b/forestry_bees/bee_drops.lua new file mode 100644 index 0000000..ee798d2 --- /dev/null +++ b/forestry_bees/bee_drops.lua @@ -0,0 +1,15 @@ +forestry_bees.bee_drops = {} + +local function register_drop(bee_type, drop_name, basechance) + if forestry_bees.bee_drops[bee_type] == nil then + forestry_bees.bee_drops[bee_type] = {} + end + forestry_bees.bee_drops[bee_type][drop_name] = basechance +end + +register_drop("forest", "forestry_bees:honey_comb", 0.3) +register_drop("meadow", "forestry_bees:honey_comb", 0.3) +register_drop("common", "forestry_bees:honey_comb", 0.35) +register_drop("cultivated", "forestry_bees:honey_comb", 0.4) +register_drop("noble", "forestry_bees:dripping_comb", 0.2) +register_drop("diligent", "forestry_bees:stringy_comb", 0.2) \ No newline at end of file diff --git a/forestry_bees/helper.lua b/forestry_bees/helper.lua index 65b4155..2b6e2ab 100644 --- a/forestry_bees/helper.lua +++ b/forestry_bees/helper.lua @@ -5,6 +5,17 @@ function forestry_bees.Bee(bee_type,active_gene,inactive_gene) return itemstack end +function forestry_bees.calculate_drop(bee_type) --later we will take as input also the bee_prod_speed and the item_modifier (for frames) + local possible_drops = forestry_bees.bee_drops[bee_type] --this gets us a table + local out_table = {} + for drop,chance in pairs(possible_drops) do + if math.random() < chance then + table.insert(out_table,ItemStack(drop)) + end + end + return out_table +end + function forestry_bees.bee_name(bee_type,active_gene) return "forestry_bees:"..active_gene.."_"..bee_type end diff --git a/forestry_bees/init.lua b/forestry_bees/init.lua index 57c868f..2a74b11 100644 --- a/forestry_bees/init.lua +++ b/forestry_bees/init.lua @@ -3,5 +3,6 @@ forestry_bees = {} dofile(minetest.get_modpath("forestry_bees") .. "/helper.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") dofile(minetest.get_modpath("forestry_bees") .. "/apiary.lua") diff --git a/forestry_bees/register.lua b/forestry_bees/register.lua index 87ddda7..ca5ab0c 100644 --- a/forestry_bees/register.lua +++ b/forestry_bees/register.lua @@ -112,5 +112,15 @@ register_bee("diligent","#ffdc16","#c219ec") minetest.register_craftitem("forestry_bees:honey_comb", { description = "Honey Comb", groups = {comb = 1}, - inventory_image = "(bee_combs.0.png^[colorize:Yellow:100)^(bee_combs.1.png^[colorize:Yellow:120)" + inventory_image = "(bee_combs.0.png^[colorize:#ffa12b:155)^(bee_combs.1.png^[colorize:#e8d56a:255)" +}) +minetest.register_craftitem("forestry_bees:dripping_comb", { + description = "Dripping Comb", + groups = {comb = 1}, + inventory_image = "(bee_combs.0.png^[colorize:#ffff00:155)^(bee_combs.1.png^[colorize:#dc7613:255)" +}) +minetest.register_craftitem("forestry_bees:stringy_comb", { + description = "Stringy Comb", + groups = {comb = 1}, + inventory_image = "(bee_combs.0.png^[colorize:#bda93e:155)^(bee_combs.1.png^[colorize:#c8be67:255)" })