Net (Multiplayer)¶
Net.register¶
Net.id¶
Lookup only.
Net.name¶
Net.startServer¶
maxClients defaults to 32.
Net.startClient¶
Net.isServer¶
Net.isNetworked¶
Net.localId¶
Net.localEntity¶
Net.maxPlayers¶
Net.on¶
Registers a packet handler. The callback receives (peer, data). data is a Lua table for
JSON payloads, a raw string otherwise, or nil for empty payloads.
Net.off¶
Net.send¶
peer may be void* or ENetPeer*. reliable defaults to false, channel to 0.
Net.broadcast¶
reliable defaults to false, channel to 0.
Net.onConnect¶
Pass nil to clear.
Net.onDisconnect¶
Pass nil to clear.
Net.peerEntity¶
Net.networkId¶
Net.playerSlot¶
Net.entityFromId¶
Net.track¶
Net.untrack¶
Net.isLocal¶
Net.input¶
Server: last input for that player. Client: local controller input if the entity is local,
else nil.
Net.replicate¶
authority defaults to "Server", syncTransform to true, syncSprite to false. Tags
an entity for replication.
Net.rpc¶
Reliable entity RPC.
Net.rpcUnreliable¶
Unreliable variant.
Net.onEntityRpc¶
Handler receives (entity, data).
Payload encoding¶
Net.oncallbackdata: JSON payloads become Lua tables; non-JSON becomes a raw string; empty payloads becomenil.EncodePayload: strings are sent raw (no JSON quoting); tables are serialized to JSON; functions/userdata become null; cycles and null are guarded.