reworked capture-dispensing

firefx
capitalthree 1 year ago
parent d4511f6d5c
commit 0e7cc27f6d
  1. 33
      rules.lua

@ -190,27 +190,30 @@ function lc_liberties.handle_placement(pos)
end end
if captured then if captured then
local removed_items = {} -- key = name, value = count
for i,v in pairs(captureses) do for i,v in pairs(captureses) do
if v.capture then 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 proximal
local old = minetest.get_node(v2).name local proximal_c = 0
removed_items[old] = (removed_items[old] or 0) + 1
for i2, v2 in pairs(v.stones) do
nodecore.set_loud(v2, {name = "nc_fire:fire"}) 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
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
end end
else else

Loading…
Cancel
Save