Skip to content
Snippets Groups Projects
Commit 619c0238 authored by Jean-Patrick Guerrero's avatar Jean-Patrick Guerrero
Browse files

Hive : stop timer when stack reaches max honey stack

parent 0422b28d
No related branches found
No related tags found
No related merge requests found
local hive = {}
local honey_max = 16
function hive.construct(pos)
local meta = minetest.get_meta(pos)
......@@ -34,8 +35,11 @@ function hive.timer(pos)
local maxp = vector.add(pos, radius)
local flowers = minetest.find_nodes_in_area_under_air(minp, maxp, "group:flower")
if #flowers > 2 and honey < 16 then
if #flowers > 2 and honey < honey_max then
inv:add_item("honey", "xdecor:honey")
elseif honey == honey_max then
local timer = minetest.get_node_timer(pos)
timer:stop() return true
end
return true
end
......@@ -55,6 +59,12 @@ xdecor.register("hive", {
on_punch = function(_, _, puncher)
puncher:set_hp(puncher:get_hp() - 2)
end,
allow_metadata_inventory_put = function() return 0 end
allow_metadata_inventory_put = function() return 0 end,
on_metadata_inventory_take = function(pos, _, _, stack)
if stack:get_count() == honey_max then
local timer = minetest.get_node_timer(pos)
timer:start(math.random(64, 128))
end
end
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment