Code:
local function checkSend(m)
if(m.playerIndex == 0 and (m.controller.buttonPressed & A_BUTTON ~=0)) then
network_send(true,{sig="testSig",msg="you have received my packet"})
end
end
local function checkReceive(packet)
log_to_console("well SOMETHING was sent")
if(packet["sig"] == "testSig") then
log_to_console(packet["msg"])
end
end
hook_event(HOOK_MARIO_UPDATE,checkSend)
hook_event(HOOK_ON_PACKET_RECEIVE,checkReceive)
network_send()
method. Whatever my understanding is, it seems to be wrong. In this code, when a local player presses the A button, I expect checkReceive()
to occur at minimum once for every player in the server and at maximum MAX_PLAYERS
times (not sure which currently). If the check of the sig
key's value in the table of the packet sent to checkReceive()
fails, I'll at least know the hook worked based on the log_to_console()
outside of that check. Additionally, I set the reliable
bool
parameter of the network_send()
call to true
so that I can be sure the packet sends lest the server desync. To my confusion, when the A button is pressed, no packet is sent based upon reading the in-game console as nothing gets logged.I have two theories as to why:
1. I'm testing this
.lua
in a server alone, perhaps network_send()
goes out to every player EXCEPT the one who sent it? The documentation for Co-Op DX did not mention this if it's true. This way, I'd simply never noticed in a 1-player server if a packet was sent since the only one to receive a packet would be the sender themselves who by definition in this theory cannot receive the packets they send.2. I'm playing on a bogus server that nobody can join via Direct Connection. This means that technically it can never be anything but a singleplayer game and perhaps networking capabilities are failing due to the bogus server config? This one seems far less likely to me than my first theory, but I thought I'd bring it up anyway.
Any ideas guys? Many thanks : )