|
13 | 13 |
|
14 | 14 | ```toml |
15 | 15 | [dependencies] |
16 | | -Lync = "axp3cter/lync@1.4.3" |
| 16 | +Lync = "axp3cter/lync@1.5.0" |
17 | 17 | ``` |
18 | 18 |
|
19 | 19 | **npm (roblox-ts)** |
|
163 | 163 | | | What it does | |
164 | 164 | |:---------|:------------| |
165 | 165 | | `Lync.start()` | Sets up transport. Server creates remotes, client connects. Call once after all definitions. | |
166 | | -| `Lync.VERSION` | `"1.4.3"` | |
| 166 | +| `Lync.VERSION` | `"1.5.0"` | |
167 | 167 |
|
168 | 168 | ## Packets |
169 | 169 |
|
@@ -228,6 +228,45 @@ packet:send(data) -- send to server |
228 | 228 |
|
229 | 229 | `Lync.defineNamespace(name, config)` returns a Namespace. Takes a `packets` table and/or a `queries` table. All names get auto-prefixed with `"YourNamespace."` so nothing collides. |
230 | 230 |
|
| 231 | +The config takes `PacketConfig` and `QueryConfig` objects (same shape you'd pass to `definePacket` / `defineQuery`). The namespace creates and owns the packets/queries internally. |
| 232 | + |
| 233 | +```luau |
| 234 | +local Combat = Lync.defineNamespace("Combat", { |
| 235 | + packets = { |
| 236 | + Hit = { |
| 237 | + value = Lync.struct({ targetId = Lync.u16, damage = Lync.f32, headshot = Lync.bool }), |
| 238 | + rateLimit = { maxPerSecond = 30, burstAllowance = 5 }, |
| 239 | + validate = function(data, player) |
| 240 | + if data.damage > 200 then return false, "damage" end |
| 241 | + return true |
| 242 | + end, |
| 243 | + }, |
| 244 | + Death = { value = Lync.u16 }, |
| 245 | + }, |
| 246 | + queries = { |
| 247 | + Stats = { |
| 248 | + request = Lync.nothing, |
| 249 | + response = Lync.struct({ kills = Lync.u16, deaths = Lync.u16 }), |
| 250 | + timeout = 3, |
| 251 | + }, |
| 252 | + }, |
| 253 | +}) |
| 254 | +
|
| 255 | +-- Access by short name directly on the namespace |
| 256 | +Combat.Hit:send(data, player) |
| 257 | +Combat.Death:listen(function(targetId, sender) end) |
| 258 | +Combat.Stats:listen(function(request, player) return { kills = 10, deaths = 2 } end) |
| 259 | +
|
| 260 | +-- Or via the typed sub-tables |
| 261 | +Combat.packets.Hit:send(data, player) |
| 262 | +Combat.queries.Stats:request(nil) |
| 263 | +``` |
| 264 | + |
| 265 | +| Config field | Type | What it does | |
| 266 | +|:-------------|:-----|:-------------| |
| 267 | +| `packets` | `{ [string]: PacketConfig }?` | Map of short name → packet config. Each entry becomes a Packet on the namespace. | |
| 268 | +| `queries` | `{ [string]: QueryConfig }?` | Map of short name → query config. Each entry becomes a Query on the namespace. | |
| 269 | + |
231 | 270 | Access packets and queries by their short name on the returned object: `ns.PacketName`, `ns.QueryName`. Or use the typed sub-tables: `ns.packets.PacketName`, `ns.queries.QueryName`. |
232 | 271 |
|
233 | 272 | | Method | What it does | |
|
0 commit comments