mirror of
https://github.com/minetest-mods/digilines.git
synced 2025-03-25 05:40:22 +01:00
Fix on_destruct() and missing 'channel'
This commit is contained in:
parent
4278dc5728
commit
785050d561
@ -18,7 +18,8 @@ local function send_and_clear_batch(pos, channel)
|
|||||||
local pos_hash = minetest.hash_node_position(pos)
|
local pos_hash = minetest.hash_node_position(pos)
|
||||||
if #batched_messages[pos_hash] == 1 then
|
if #batched_messages[pos_hash] == 1 then
|
||||||
-- If there is only one message is the batch, don't send it in a batch
|
-- If there is only one message is the batch, don't send it in a batch
|
||||||
digilines.receptor_send(pos, digilines.rules.default, next(batched_messages[pos_hash]))
|
digilines.receptor_send(pos, digilines.rules.default, channel,
|
||||||
|
next(batched_messages[pos_hash]))
|
||||||
else
|
else
|
||||||
digilines.receptor_send(pos, digilines.rules.default, channel, {
|
digilines.receptor_send(pos, digilines.rules.default, channel, {
|
||||||
action = "batch",
|
action = "batch",
|
||||||
@ -29,6 +30,14 @@ local function send_and_clear_batch(pos, channel)
|
|||||||
last_message_time_for_chest[pos_hash] = nil
|
last_message_time_for_chest[pos_hash] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function flush_batch_for_chest(pos)
|
||||||
|
if not batched_messages[minetest.hash_node_position(pos)] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local channel = minetest.get_meta(pos):get_string("channel")
|
||||||
|
send_and_clear_batch(pos, channel)
|
||||||
|
end
|
||||||
|
|
||||||
-- Sends a message onto the Digilines network.
|
-- Sends a message onto the Digilines network.
|
||||||
-- pos: the position of the Digilines chest node.
|
-- pos: the position of the Digilines chest node.
|
||||||
-- action: the action string indicating what happened.
|
-- action: the action string indicating what happened.
|
||||||
@ -235,7 +244,7 @@ minetest.register_node("digilines:chest", {
|
|||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
batched_messages[minetest.hash_node_position(pos)] = nil
|
flush_batch_for_chest(pos)
|
||||||
end,
|
end,
|
||||||
after_place_node = tubescan,
|
after_place_node = tubescan,
|
||||||
after_dig_node = tubescan,
|
after_dig_node = tubescan,
|
||||||
@ -375,11 +384,7 @@ minetest.register_node("digilines:chest", {
|
|||||||
end,
|
end,
|
||||||
on_timer = function(pos, _)
|
on_timer = function(pos, _)
|
||||||
-- Send all the batched messages when enough time since the last message passed
|
-- Send all the batched messages when enough time since the last message passed
|
||||||
if not batched_messages[minetest.hash_node_position(pos)] then
|
flush_batch_for_chest(pos)
|
||||||
return
|
|
||||||
end
|
|
||||||
local channel = minetest.get_meta(pos):get_string("channel")
|
|
||||||
send_and_clear_batch(pos, channel)
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user