From ad6d4c9c679c8579bc95a0fe4863759126c340a0 Mon Sep 17 00:00:00 2001 From: capitalthree Date: Sat, 25 Nov 2023 21:33:38 -0600 Subject: [PATCH] proper smoke handling (maybe), and nice restacking of tokens grabbed as group --- rules.lua | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/rules.lua b/rules.lua index 8ee007a..d291d5a 100644 --- a/rules.lua +++ b/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