Module Functions
Top-level functions exposed directly on the KravasNet table.
KravasNet.createNamespace
KravasNet.createNamespace(name: string, initialChannels: {[string]: schema | PacketDef}?): NamespaceCreates a new Namespace — the main container for grouping related channels. Internally maps to exactly one ByteNet.defineNamespace(name, ...) call, deferred until build time.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the namespace. Passed straight through to ByteNet.defineNamespace. Must be unique across your whole game. |
initialChannels | {[string]: schema | PacketDef} | No | Channels to queue immediately. Values can be a raw schema table (defaults to reliable, no middleware) or a KravasNet.packet() definition. |
Returns: the new Namespace, with its channels still pending (not yet built).
local CombatNet = KravasNet.createNamespace("Combat", {
Damage = { amount = KravasNet.float32 },
})
CombatNet:build()KravasNet.createChannel
KravasNet.createChannel(schema: {[string]: any}, options: ChannelOptions?): ChannelCreates a standalone Channel without attaching it to a user-named namespace. Internally, this generates its own auto-named, immediately-built ByteNet.defineNamespace (named KravasNet_Channel_<n>) so it can register a packet on its own.
| Parameter | Type | Required | Description |
|---|---|---|---|
schema | {[string]: any} | Yes | Field-to-type map. Wrapped internally with ByteNet.struct(schema). |
options | ChannelOptions | No | See Middleware & Reliability. |
Returns: a ready-to-use Channel — no separate build step needed.
local HealthChannel = KravasNet.createChannel({
current = KravasNet.uint8,
max = KravasNet.uint8,
})Every call to createChannel registers a brand-new anonymous ByteNet
namespace. Prefer grouping related channels under one
KravasNet.createNamespace() instead of calling createChannel in a
loop — each standalone channel has its own network registration overhead.
KravasNet.packet
KravasNet.packet(schema: {[string]: any}, options: ChannelOptions?): PacketDefBuilds a PacketDef — a wrapper bundling a schema together with its ChannelOptions. Used exclusively as a value inside the initialChannels table passed to createNamespace, since plain schema tables there can't carry options on their own.
local CombatNet = KravasNet.createNamespace("Combat", {
Position = KravasNet.packet({ pos = KravasNet.vec3 }, { reliability = "unreliable" }),
})KravasNet.ByteNet
KravasNet.ByteNet: ByteNetDirect reference to the underlying ByteNet module, exposed as an escape hatch for cases the abstraction doesn't cover (e.g. calling ByteNet.defineNamespace yourself for something highly custom).