now bees need certain conditions to work (e.g. day, sky access...)

This commit is contained in:
Alessio Rondelli 2024-10-12 18:39:42 +02:00
parent e099b13af2
commit 4685008ff7
2 changed files with 18 additions and 1 deletions

View File

@ -129,8 +129,9 @@ local function apiary_node_timer(pos,elapsed)
inv:set_stack("drone",1,bee)
end
---------------------
can_breed = is_princess and is_drone
can_live = is_queen --these two event are disjoint (there are no queen & princess)
can_live = is_queen and forestry_bees.can_queen_work(monarchlist[1], pos) --these two event are disjoint (there are no queen & princess)
actionable = can_breed or can_live
if is_queen then

View File

@ -16,6 +16,22 @@ function forestry_bees.Bee(bee_type,genes)
return itemstack
end
function forestry_bees.can_queen_work(queen, pos)
local genes = minetest.deserialize(queen:get_meta():get_string("genes"))
local biome_data = minetest.get_biome_data(pos)
local biome_name = minetest.get_biome_name(biome_data["biome"])
local humidity = biome_data["humidity"]
local heat = biome_data["heat"]
--now get the environmental data
local is_right_heat = true --futureproofing
local is_right_humidity = true --futureproofing
local is_right_biome = true --futureproofing
local is_sky_access = (genes["cave"][1] or (minetest.get_natural_light(vector.offset(pos, 0, 1, 0), 0.5) == 15))
local is_not_raining = (genes["flyer"][1] or true) --would require additional mods
local is_day = (genes["nocturnal"][1] or ((0.25 < minetest.get_timeofday()) and (minetest.get_timeofday() < 0.75)))
return is_sky_access and is_not_raining and is_day
end
function forestry_bees.calculate_drop(bee)
local genes = minetest.deserialize(bee:get_meta():get_string("genes"))
local possible_drops = forestry_bees.bee_drops[genes["type_gene"][1]] --this gets us a table