diff --git a/digiline.lua b/digiline.lua index 3f47e96..adc1e08 100644 --- a/digiline.lua +++ b/digiline.lua @@ -31,7 +31,7 @@ spacecannon.digiline_handler_get = function(pos, node, channel) digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp) end -spacecannon.digiline_handler_fire = function(pos, node, channel) +spacecannon.digiline_handler_fire = function(pos, node, channel, msg) local meta = minetest.get_meta(pos) -- TODO: Add ability to set "target node" in the msg, and if its within @@ -60,7 +60,14 @@ spacecannon.digiline_handler_fire = function(pos, node, channel) pos = pos } - digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp) + -- Only send response if the fire request specifically asked for it. + -- Consider a large (N) bank of cannons on the same digiline. Firing all N + -- at the same time would generate N responses, which would be seen by the LUAC + -- and the (N-1) other cannons, resulting in N^2 message processing. If N>20, + -- the LUAC will get fried. + if msg.verbose then + digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp) + end end spacecannon.digiline_effector = function(pos, node, channel, msg) diff --git a/readme.md b/readme.md index 2a29ed7..8471970 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ An "on" signal triggers a fire-action. Fire a cannon: ```lua if event.type == "program" then - digiline_send("cannon", { command="fire" }) + digiline_send("cannon", { command="fire", verbose=false }) end ``` @@ -66,7 +66,14 @@ Example response from a "get" request: } ``` -Example response from a "fire" request: +The "fire" request can specify an optional "verbose" flag. If this flag +evaluates to true, then the following example response will be sent back. +Note that if you have a large number of cannons that you will likely want +to disable responses. N cannons firing and generating responses will +cause N^2 messages to be processed, as each cannon receives the fire response +from all of its peers. If N>20, your LUAC will overheat. N>900, and your +server admin will want to have a chat with you. + ```lua { type = "digiline",