diff --git a/rules.lua b/rules.lua index c958695..820bd80 100644 --- a/rules.lua +++ b/rules.lua @@ -190,27 +190,30 @@ 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 = {} + local stone = minetest.get_node(v.stones[next(v.stones)]).name + local count = 0 - for i2, v2 in pairs(v.stones) do - local old = minetest.get_node(v2).name - removed_items[old] = (removed_items[old] or 0) + 1 + local proximal + local proximal_c = 0 + for i2, v2 in pairs(v.stones) do nodecore.set_loud(v2, {name = "nc_fire:fire"}) + count = count + 1 + if (v2:distance(pos) < 2.3) then + proximal_c = proximal_c + 1 + if math.random(1, proximal_c) == 1 then + proximal = v2 + end + end + end + + local stack_max = minetest.registered_items[stone].stack_max + while count > 0 do + nodecore.item_eject(proximal, stone .. " " .. math.min(count, stack_max)) + count = count - stack_max end - 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