proper smoke handling (maybe), and nice restacking of tokens grabbed as group

master
capitalthree 1 year ago
parent b1828a3e4c
commit ad6d4c9c67
  1. 29
      rules.lua

@ -231,6 +231,16 @@ local function territory_search(pos, max)
)
end
local function multi_eject(proximal, stone, speed, count, inv)
local stack_max = minetest.registered_items[stone].stack_max
while count > 0 do
local items = stone .. " " .. math.min(count, stack_max)
if inv then items = inv:add_item("main", items) end
nodecore.item_eject(proximal, items, speed)
count = count - stack_max
end
end
function lc_liberties.handle_placement(pos)
cache = {}
--minetest.chat_send_all(tostring(pos))
@ -291,11 +301,7 @@ function lc_liberties.handle_placement(pos)
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), 3)
count = count - stack_max
end
multi_eject(proximal, stone, 3, count)
end
end
else
@ -308,7 +314,7 @@ function lc_liberties.handle_placement(pos)
for x=pos.x-18, pos.x+18 do
for z=pos.z-18, pos.z+18 do
if (x ~= pos.x) or (z ~= pos.z) then
nodecore.smokequell({x = x, y = pos.y, z = z})
nodecore.smokeclear({x = x, y = pos.y, z = z})
end
end
end
@ -351,12 +357,21 @@ function lc_liberties.handle_dig(pos, node, digger)
~=
(minetest.registered_items[node.name].groups.go_territory_marker ~= nil)
then
local stone = minetest.get_node(pos).name
local count = 0
for i, v in pairs(connected_group(pos)) do
minetest.node_dig(v, node, digger)
count = count + 1
nodecore.smokeclear(v)
nodecore.set_loud(v, {name = "air"})
end
multi_eject(pos, stone, 1, count, digger and digger:get_inventory())
return true
else
nodecore.smokeclear(pos)
return minetest.node_dig(pos, node, digger)
end
end

Loading…
Cancel
Save