diff --git a/rules.lua b/rules.lua index 5cc2db4..ccc5035 100644 --- a/rules.lua +++ b/rules.lua @@ -355,8 +355,9 @@ function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) return ret end + local under if (pointed_thing and pointed_thing.under) then - local under = minetest.get_node(pointed_thing.under) + under = minetest.get_node(pointed_thing.under) local override_rightclick = minetest.registered_nodes[under.name].on_rightclick if override_rightclick then return override_rightclick(pointed_thing.under, under, placer, itemstack, pointed_thing) @@ -364,8 +365,17 @@ function lc_liberties.handle_territory_fill(itemstack, placer, pointed_thing) end if pointed_thing and pointed_thing.above then - cache = {} + if under then + local reg_item = minetest.registered_items[under.name] + if reg_item and reg_item.groups and reg_item.groups.go_stone then + nodecore.set_loud(pointed_thing.above, {name = modname .. ":territory_" .. reg_item.go_team}) + itemstack:set_count(itemstack:get_count() - 1) + return itemstack + end + end + + cache = {} local territories = territory_search(pointed_thing.above, itemstack:get_count()) if territories.team then local piece = modname .. ":territory_" .. territories.team