From 0a2a4e4cdaa579189e865e24fa059f0e36cdc801 Mon Sep 17 00:00:00 2001 From: capitalthree Date: Thu, 30 Nov 2023 19:53:01 -0600 Subject: [PATCH] stop stones will default to placing a single stone, and matching color, if placed on top of a go stone --- rules.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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