Better fix for #16

This commit is contained in:
upsilon 2021-03-07 10:40:05 +01:00
parent 021100b3d4
commit 182eb9822a
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C

@ -253,6 +253,9 @@ function wireless_effector_off(pos)
update_mod_storage() update_mod_storage()
end end
-- This table is required to prevent a message from being sent in loop between wireless nodes
local sending_digilines = {}
local function on_digiline_receive(pos, node, channel, msg) local function on_digiline_receive(pos, node, channel, msg)
if is_jammed(pos) then if is_jammed(pos) then
return return
@ -264,14 +267,18 @@ local function on_digiline_receive(pos, node, channel, msg)
return return
end end
-- Why is delaying required? https://github.com/minetest-mods/MoreMesecons/issues/16 local pos_hash = minetest.hash_node_position(pos)
minetest.after(0, function() if sending_digilines[pos_hash] then
for i, wl_pos in pairs(wireless[wls.owner][wls.channel].members) do return
if i ~= wls.id and check_wireless_exists(wl_pos) then end
digiline:receptor_send(wl_pos, digiline.rules.default, channel, msg)
end sending_digilines[pos_hash] = true
for i, wl_pos in pairs(wireless[wls.owner][wls.channel].members) do
if i ~= wls.id and check_wireless_exists(wl_pos) then
digiline:receptor_send(wl_pos, digiline.rules.default, channel, msg)
end end
end) end
sending_digilines[pos_hash] = nil
end end
mesecon.register_node("moremesecons_wireless:wireless", { mesecon.register_node("moremesecons_wireless:wireless", {