Make pots drop separately from the plants within.

This makes them attached nodes. This also makes digging a
pot with plant drop the plant as item and leave an empty pot
in the ground.
This commit is contained in:
Auke Kok 2017-02-10 20:34:14 -08:00
parent cb7770dac0
commit 550a47f791

View File

@ -106,9 +106,22 @@ function flowerpot.register_node(nodename)
fixed = {-1/4, -1/2, -1/4, 1/4, 7/16, 1/4},
},
sounds = default.node_sound_defaults(),
groups = {oddly_breakable_by_hand = 1, snappy = 3, not_in_creative_inventory = 1},
groups = {attached_node = 1, oddly_breakable_by_hand = 1, snappy = 3, not_in_creative_inventory = 1},
flowerpot_plantname = nodename,
on_punch = flowerpot_on_punch,
on_dig = function(pos, node, digger)
minetest.set_node(pos, {name = "flowerpot:empty"})
local def = minetest.registered_nodes[node.name]
minetest.add_item(pos, nodename)
end,
drop = {
max_items = 2,
items = {
{
items = {"flowerpot:empty", nodename},
rarity = 1,
},
}
},
})
end
@ -134,7 +147,7 @@ minetest.register_node("flowerpot:empty", {
fixed = {-1/4, -1/2, -1/4, 1/4, -1/16, 1/4},
},
sounds = default.node_sound_defaults(),
groups = {oddly_breakable_by_hand = 3, cracky = 1, dig_immediate = 3},
groups = {attached_node = 1, oddly_breakable_by_hand = 3, cracky = 1, dig_immediate = 3},
on_rightclick = flowerpot_on_rightclick,
})