Fix Lua UDP before startup and without script commands

send_udp and get_host_udp_port indexed script data that is only created
on the first tick after patching, so calling them from on_init stopped
the server. They now return nothing until then.

Received packets were only polled once the host port was known, which
needs script commands. Poll whenever recv_udp exists instead, it does
nothing when the server runs without --enable-lua-udp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-17 10:29:35 +00:00
1 parent 25c3c9991e
commit 0a6f614074
3 files changed
+64 -5

No files matched your search

+2 -1
View File
@@ -44,7 +44,8 @@ function api.send_json(channel, data)
end
function api.send_udp(channel, data)
local port = compat.script_data.clusterio.host_udp_port
local clusterio = compat.script_data.clusterio
local port = clusterio and clusterio.host_udp_port
if not port then
return -- Lua UDP is not enabled for this instance
end