From ce951072b52d742b89a45f8095870ee9509bdfbf Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Mon, 20 Nov 2023 12:45:10 -0500 Subject: [PATCH] Drop captured go stones when capturing --- rules.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rules.lua b/rules.lua index 0a3891e..c958695 100644 --- a/rules.lua +++ b/rules.lua @@ -190,15 +190,27 @@ function lc_liberties.handle_placement(pos) end if captured then + local removed_items = {} -- key = name, value = count for i,v in pairs(captureses) do if v.capture then local proximal = {} for i2, v2 in pairs(v.stones) do + local old = minetest.get_node(v2).name + removed_items[old] = (removed_items[old] or 0) + 1 + nodecore.set_loud(v2, {name = "nc_fire:fire"}) end - - -- todo: spawn itemstack of captured stones somehow + end + end + for k, v in pairs(removed_items) do + local max = minetest.registered_items[k].stack_max + while v > max do + nodecore.item_eject(pos, k .. " " .. max) + v = v - max + end + if v > 0 then + nodecore.item_eject(pos, k .. " " .. v) end end else