mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2024-12-21 05:15:47 +01:00
Make cannon 'fire' response optional, defaulting to off.
This commit is contained in:
parent
8450e4ac70
commit
e7f3f1eac6
@ -31,7 +31,7 @@ spacecannon.digiline_handler_get = function(pos, node, channel)
|
|||||||
digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp)
|
digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp)
|
||||||
end
|
end
|
||||||
|
|
||||||
spacecannon.digiline_handler_fire = function(pos, node, channel)
|
spacecannon.digiline_handler_fire = function(pos, node, channel, msg)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
-- TODO: Add ability to set "target node" in the msg, and if its within
|
-- TODO: Add ability to set "target node" in the msg, and if its within
|
||||||
@ -60,8 +60,15 @@ spacecannon.digiline_handler_fire = function(pos, node, channel)
|
|||||||
pos = pos
|
pos = pos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- 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)
|
digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
spacecannon.digiline_effector = function(pos, node, channel, msg)
|
spacecannon.digiline_effector = function(pos, node, channel, msg)
|
||||||
if type(msg) ~= "table" then
|
if type(msg) ~= "table" then
|
||||||
|
11
readme.md
11
readme.md
@ -36,7 +36,7 @@ An "on" signal triggers a fire-action.
|
|||||||
Fire a cannon:
|
Fire a cannon:
|
||||||
```lua
|
```lua
|
||||||
if event.type == "program" then
|
if event.type == "program" then
|
||||||
digiline_send("cannon", { command="fire" })
|
digiline_send("cannon", { command="fire", verbose=false })
|
||||||
end
|
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
|
```lua
|
||||||
{
|
{
|
||||||
type = "digiline",
|
type = "digiline",
|
||||||
|
Loading…
Reference in New Issue
Block a user