@s2script/sdk 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/clients.d.ts +88 -0
- package/dist/cli.js +359 -241
- package/entity.d.ts +106 -1
- package/index.d.ts +1 -0
- package/package.json +4 -1
- package/plugin.d.ts +20 -2
- package/sdkhooks.d.ts +26 -3
- package/sound.d.ts +54 -0
- package/stringtables.d.ts +63 -0
package/entity.d.ts
CHANGED
|
@@ -185,6 +185,38 @@ export declare class EntityRef {
|
|
|
185
185
|
* `trigger_multiple` needs a model to build the physics volume that fires touch. Returns false
|
|
186
186
|
* if the op is unavailable or the ref is stale. */
|
|
187
187
|
setModel(name: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The index of the bone called `name` on this entity's model, for {@link getBoneTransform}.
|
|
190
|
+
* `-1` when the model has no such bone, the entity has no model, or the ref is stale.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* const head = pawn.ref.lookupBone("head_0");
|
|
194
|
+
* const t = head >= 0 ? pawn.ref.getBoneTransform(head) : null;
|
|
195
|
+
* if (t) console.log(`head at ${t.position}`);
|
|
196
|
+
*/
|
|
197
|
+
lookupBone(name: string): number;
|
|
198
|
+
/**
|
|
199
|
+
* Where bone `bone` is right now, in world space: its position and its orientation as a
|
|
200
|
+
* quaternion. `null` for a stale ref, an entity with no model, or a negative index. An index past
|
|
201
|
+
* the model's last bone gives the entity's own transform, as the engine does.
|
|
202
|
+
*/
|
|
203
|
+
getBoneTransform(bone: number): BoneTransform | null;
|
|
204
|
+
/**
|
|
205
|
+
* The index of the attachment called `name` on this entity's model (`"muzzle_flash"`,
|
|
206
|
+
* `"eyes"`), for {@link getAttachment}. `0` when there is no such attachment, the entity has no
|
|
207
|
+
* model, or the ref is stale; real attachments start at 1.
|
|
208
|
+
*/
|
|
209
|
+
lookupAttachment(name: string): number;
|
|
210
|
+
/**
|
|
211
|
+
* Where attachment `attachment` is right now, in world space. `null` for a stale ref, an entity
|
|
212
|
+
* with no model, an index outside 1–255, or an attachment the engine did not find.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* const muzzle = weapon.ref.lookupAttachment("muzzle_flash");
|
|
216
|
+
* const at = weapon.ref.getAttachment(muzzle);
|
|
217
|
+
* if (at) console.log(`muzzle at ${at.origin}, facing ${at.angles}`);
|
|
218
|
+
*/
|
|
219
|
+
getAttachment(attachment: number): AttachmentTransform | null;
|
|
188
220
|
/** Set this entity's gravity multiplier (`CBaseEntity::SetGravityScale`). 1 is normal, 0 is
|
|
189
221
|
* weightless.
|
|
190
222
|
*
|
|
@@ -229,6 +261,35 @@ export declare class EntityRef {
|
|
|
229
261
|
* output the input triggers. `delay` queues the event on the engine's same-tick I/O pump (0 = fires
|
|
230
262
|
* this same tick — NOT synchronous-within-the-call). Returns false with no op / a stale ref. */
|
|
231
263
|
acceptInput(input: string, value?: string, activator?: EntityRef, caller?: EntityRef, delay?: number): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Deal `damage` to this entity through the game's own damage path, so `OnTakeDamage` hooks and
|
|
266
|
+
* the game's rules (god mode, friendly fire, armor) still apply. The engine may still refuse it,
|
|
267
|
+
* for example when the entity doesn't take damage at all. Returns false when the call was refused:
|
|
268
|
+
* a stale victim or option entity, a non-finite `damage`, or an unavailable game function.
|
|
269
|
+
* @example
|
|
270
|
+
* // 25 damage from `attacker`'s pawn, as a bullet (CS2's DMG_BULLET is 2).
|
|
271
|
+
* victim.takeDamage(25, { attacker: attackerPawn.ref, damageType: 2 });
|
|
272
|
+
*/
|
|
273
|
+
takeDamage(damage: number, opts?: TakeDamageOptions): boolean;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** An entity option of {@link EntityRef.takeDamage}: an EntityRef, or a wrapper that holds one. */
|
|
277
|
+
export type DamageEntity = EntityRef | { readonly ref: EntityRef };
|
|
278
|
+
|
|
279
|
+
/** Options for {@link EntityRef.takeDamage}. Every field is optional. */
|
|
280
|
+
export interface TakeDamageOptions {
|
|
281
|
+
/** Who gets credit for the damage (the damage info's attacker). */
|
|
282
|
+
attacker?: DamageEntity | null;
|
|
283
|
+
/** What dealt it, such as a grenade or the attacker's weapon. Defaults to the attacker. */
|
|
284
|
+
inflictor?: DamageEntity | null;
|
|
285
|
+
/** The weapon or ability it came from (SourceMod's `weapon`). */
|
|
286
|
+
ability?: DamageEntity | null;
|
|
287
|
+
/** Damage-type bit flags; the values are game facts (CS2: `DamageTypes_t`). Defaults to 0 (generic). */
|
|
288
|
+
damageType?: number;
|
|
289
|
+
/** Damage force, `[x, y, z]`. Defaults to zero. */
|
|
290
|
+
force?: ArrayLike<number> | null;
|
|
291
|
+
/** Where the damage lands, `[x, y, z]`. Defaults to zero. */
|
|
292
|
+
position?: ArrayLike<number> | null;
|
|
232
293
|
}
|
|
233
294
|
|
|
234
295
|
/** Element kinds for {@link EntityRef.gather} plans — the scalar kinds a `Float64Array` holds exactly. */
|
|
@@ -274,14 +335,58 @@ export interface OutputEvent {
|
|
|
274
335
|
delay: number;
|
|
275
336
|
}
|
|
276
337
|
|
|
338
|
+
/** The payload delivered to an `onInput` handler. */
|
|
339
|
+
export interface InputEvent {
|
|
340
|
+
/** The input's name as the engine spelled it (e.g. "Kill", "Open", "SetHealth"). */
|
|
341
|
+
input: string;
|
|
342
|
+
/** The entity receiving the input, or null if it is no longer live. */
|
|
343
|
+
entity: EntityRef | null;
|
|
344
|
+
/** The entity that activated the chain leading to this input, or null. */
|
|
345
|
+
activator: EntityRef | null;
|
|
346
|
+
/** The entity that sent the input (the output's owner, for map I/O), or null. */
|
|
347
|
+
caller: EntityRef | null;
|
|
348
|
+
/**
|
|
349
|
+
* The input's parameter, formatted as a string ("" when it has none). Inputs fired with a Pulse
|
|
350
|
+
* argument pack instead of a variant also report "".
|
|
351
|
+
*/
|
|
352
|
+
value: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
277
355
|
/**
|
|
278
|
-
* Entry point for entity lookup by class name.
|
|
356
|
+
* Entry point for entity lookup by class name, targetname or position.
|
|
279
357
|
* @example
|
|
280
358
|
* import { Entity } from "@s2script/sdk/entity";
|
|
281
359
|
* const triggers = Entity.findByClass("trigger_multiple");
|
|
282
360
|
* for (const t of triggers) console.log(t.index, t.name);
|
|
361
|
+
* const doors = Entity.findByName("cell_doors");
|
|
362
|
+
* const nearby = Entity.findInSphere([0, 0, 64], 256, "prop_physics");
|
|
283
363
|
*/
|
|
284
364
|
export declare const Entity: {
|
|
285
365
|
/** Find every entity whose designer-name (class) exactly matches `className`. Returns liveness-gated refs. */
|
|
286
366
|
findByClass(className: string): EntityRef[];
|
|
367
|
+
/** Find every entity whose targetname (`name`, the map's `targetname`) exactly matches `name`.
|
|
368
|
+
* An empty `name` matches nothing. Returns liveness-gated refs. */
|
|
369
|
+
findByName(name: string): EntityRef[];
|
|
370
|
+
/** Every entity whose world origin is within `radius` units of `center` (inclusive), optionally only
|
|
371
|
+
* those of `className`. Entities without a readable origin are skipped. Returns `[]` for a
|
|
372
|
+
* non-finite center or a negative radius. Without `className` this walks every entity, so prefer
|
|
373
|
+
* passing one in hot paths. */
|
|
374
|
+
findInSphere(center: Vector | { x: number; y: number; z: number } | [number, number, number],
|
|
375
|
+
radius: number, className?: string): EntityRef[];
|
|
287
376
|
};
|
|
377
|
+
|
|
378
|
+
/** What {@link EntityRef.getBoneTransform} returns. */
|
|
379
|
+
export interface BoneTransform {
|
|
380
|
+
/** The bone's world position. */
|
|
381
|
+
position: Vector;
|
|
382
|
+
/** The bone's world orientation, as a unit quaternion. */
|
|
383
|
+
rotation: { x: number; y: number; z: number; w: number };
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** What {@link EntityRef.getAttachment} returns. */
|
|
387
|
+
export interface AttachmentTransform {
|
|
388
|
+
/** The attachment's world position. */
|
|
389
|
+
origin: Vector;
|
|
390
|
+
/** The attachment's world angles. */
|
|
391
|
+
angles: QAngle;
|
|
392
|
+
}
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s2script/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"description": "s2script SDK — the builtin capability types (imported as @s2script/sdk/entity, …) plus the `s2s` CLI for building Source 2 / CS2 plugins.",
|
|
6
6
|
"type": "module",
|
|
@@ -134,6 +134,9 @@
|
|
|
134
134
|
"./usermessages": {
|
|
135
135
|
"types": "./usermessages.d.ts"
|
|
136
136
|
},
|
|
137
|
+
"./stringtables": {
|
|
138
|
+
"types": "./stringtables.d.ts"
|
|
139
|
+
},
|
|
137
140
|
"./voice": {
|
|
138
141
|
"types": "./voice.d.ts"
|
|
139
142
|
},
|
package/plugin.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
*/
|
|
19
19
|
import type { GameEvent, HookResultValue } from "./events";
|
|
20
20
|
import type { Client } from "./clients";
|
|
21
|
-
import type { EntityRef, OutputEvent } from "./entity";
|
|
21
|
+
import type { EntityRef, InputEvent, OutputEvent } from "./entity";
|
|
22
22
|
import type { CommandHandler } from "./commands";
|
|
23
23
|
import type { Config } from "./config";
|
|
24
24
|
import type { PublishHandle } from "./interfaces";
|
|
@@ -100,6 +100,12 @@ export interface CtxEntities {
|
|
|
100
100
|
output: string,
|
|
101
101
|
handler: (ev: OutputEvent) => HookResultValue | void
|
|
102
102
|
): void;
|
|
103
|
+
/** Hook an input an entity receives (`AcceptInput`); return a {@link HookResultValue} to drop it. */
|
|
104
|
+
onInput(
|
|
105
|
+
classname: string,
|
|
106
|
+
input: string,
|
|
107
|
+
handler: (ev: InputEvent) => HookResultValue | void
|
|
108
|
+
): void;
|
|
103
109
|
}
|
|
104
110
|
/** Per-frame + map/precache hooks on this plugin's load-scope ({@link PluginContext.server}). */
|
|
105
111
|
export interface CtxServer {
|
|
@@ -298,7 +304,7 @@ export interface PluginHooks {
|
|
|
298
304
|
*
|
|
299
305
|
* `OnGameFrame` is SourceMod's public (before simulation). Post-simulation paint is
|
|
300
306
|
* {@link Scope}'s `server.onGameFrame(fn, { phase: "post" })` — Metamod's post hook, not a SM public.
|
|
301
|
-
* Filtered entity I/O is {@link onOutput}, not a public — SourceMod `HookEntityOutput`.
|
|
307
|
+
* Filtered entity I/O is {@link onOutput} / {@link onInput}, not a public — SourceMod `HookEntityOutput`.
|
|
302
308
|
* Per-entity damage is `SDKHook` (`SDKHookType.OnTakeDamage`), not a named public.
|
|
303
309
|
*/
|
|
304
310
|
|
|
@@ -328,6 +334,18 @@ export declare function onOutput(
|
|
|
328
334
|
handler: (ev: OutputEvent) => HookResultValue | void
|
|
329
335
|
): void;
|
|
330
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Load-window entity input hook (SourceMod-style `AcceptEntityInput` pre-hook), called before the
|
|
339
|
+
* receiving entity runs the input. Keyed by `(classname, input)`; input names match
|
|
340
|
+
* case-insensitively and `"*"` wildcards either side. Return {@link HookResultValue} `Handled`/`Stop`
|
|
341
|
+
* to drop the input. Throws after settle.
|
|
342
|
+
*/
|
|
343
|
+
export declare function onInput(
|
|
344
|
+
classname: string,
|
|
345
|
+
input: string,
|
|
346
|
+
handler: (ev: InputEvent) => HookResultValue | void
|
|
347
|
+
): void;
|
|
348
|
+
|
|
331
349
|
/**
|
|
332
350
|
* The revived hot-reload handoff (the previous instance's `OnPluginState` return), or `undefined`.
|
|
333
351
|
* Load-window only.
|
package/sdkhooks.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @s2script/sdkhooks — per-entity SDKHooks (SourceMod `SDKHook` / `SDKUnhook`).
|
|
3
3
|
* NO runtime code: the engine injects the implementation at load time.
|
|
4
4
|
*/
|
|
5
|
-
import type { EntityRef } from "./entity";
|
|
5
|
+
import type { DamageEntity, EntityRef } from "./entity";
|
|
6
6
|
import type { DamageInfo } from "./damage";
|
|
7
7
|
import type { HookResultValue } from "./events";
|
|
8
8
|
import type { Client } from "./clients";
|
|
@@ -87,7 +87,10 @@ export declare const SDKHookType: {
|
|
|
87
87
|
readonly Spawn: "Spawn";
|
|
88
88
|
/** `Spawn` post. Return is ignored. */
|
|
89
89
|
readonly SpawnPost: "SpawnPost";
|
|
90
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* `CBaseEntity::Think` pre. Source 2 has no Think virtual (thinks are `SetThink` function
|
|
92
|
+
* pointers), so on CS2 {@link SDKHook} returns `false` for this type.
|
|
93
|
+
*/
|
|
91
94
|
readonly Think: "Think";
|
|
92
95
|
/** `Think` post. Return is ignored. */
|
|
93
96
|
readonly ThinkPost: "ThinkPost";
|
|
@@ -99,7 +102,10 @@ export declare const SDKHookType: {
|
|
|
99
102
|
readonly PostThink: "PostThink";
|
|
100
103
|
/** `PostThink` post. Return is ignored. */
|
|
101
104
|
readonly PostThinkPost: "PostThinkPost";
|
|
102
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* `CBaseEntity::Use` pre (`+use` on a door, button or prop). `Handled` / `Stop` skip the
|
|
107
|
+
* original virtual.
|
|
108
|
+
*/
|
|
103
109
|
readonly Use: "Use";
|
|
104
110
|
/** `Use` post. Return is ignored. */
|
|
105
111
|
readonly UsePost: "UsePost";
|
|
@@ -546,3 +552,20 @@ export declare function SDKUnhook(
|
|
|
546
552
|
type: "ReloadPost",
|
|
547
553
|
callback: ReloadPostCallback,
|
|
548
554
|
): boolean;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* SourceMod's `SDKHooks_TakeDamage`: deal damage to `entity` through the game's own damage path.
|
|
558
|
+
* The same call as {@link EntityRef.takeDamage}; `weapon` is its `ability`. Unlike SourceMod there
|
|
559
|
+
* is no `bypassHooks`: `OnTakeDamage` hooks always see damage a plugin deals. Returns false when
|
|
560
|
+
* the call was refused (a null or stale entity, a non-finite `damage`, an unavailable game function).
|
|
561
|
+
*/
|
|
562
|
+
export declare function SDKHooks_TakeDamage(
|
|
563
|
+
entity: DamageEntity | null,
|
|
564
|
+
inflictor: DamageEntity | null,
|
|
565
|
+
attacker: DamageEntity | null,
|
|
566
|
+
damage: number,
|
|
567
|
+
damageType?: number,
|
|
568
|
+
weapon?: DamageEntity | null,
|
|
569
|
+
force?: ArrayLike<number> | null,
|
|
570
|
+
position?: ArrayLike<number> | null,
|
|
571
|
+
): boolean;
|
package/sound.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @s2script/sound — engine-generic sound: emit a named SoundEvent + register custom precache paths. */
|
|
2
2
|
import type { EntityRef } from "./entity";
|
|
3
|
+
import type { Vector } from "./math";
|
|
3
4
|
|
|
4
5
|
/** Options for {@link Sound.emit} — the source entity, recipient slots, and volume. */
|
|
5
6
|
export interface SoundEmitOptions {
|
|
@@ -14,6 +15,42 @@ export interface SoundEmitOptions {
|
|
|
14
15
|
volume?: number;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
/** Recipients for {@link SoundEvent.setParam} and {@link SoundEvent.stop}. */
|
|
19
|
+
export interface SoundEventRecipients {
|
|
20
|
+
/** Player slots the change goes to. Omitted -> every valid client. Bots are skipped. */
|
|
21
|
+
recipients?: number[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A sound started with {@link Sound.start}: the engine's event guid and stack hash. It is plain
|
|
26
|
+
* data, so it is safe to keep. Once the sound has finished, `setParam` and `stop` still return true
|
|
27
|
+
* but the engine ignores them.
|
|
28
|
+
*/
|
|
29
|
+
export interface SoundEvent {
|
|
30
|
+
/** The engine sound event guid, the same number {@link Sound.emit} returns. */
|
|
31
|
+
readonly guid: number;
|
|
32
|
+
/** The event's stack hash, which the engine needs alongside the guid to set a parameter. */
|
|
33
|
+
readonly stackHash: number;
|
|
34
|
+
/**
|
|
35
|
+
* Set a soundevent parameter on the playing sound, for example `"volume"`, `"pitch"` or
|
|
36
|
+
* `"position"`, or one of the event's own `public.*` fields. A number sets a float field and a
|
|
37
|
+
* Vector sets a three-float field.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const ev = Sound.start("MyPack.Siren", { entity: pawn.ref });
|
|
41
|
+
* ev?.setParam("volume", 0.4);
|
|
42
|
+
* ev?.setParam("position", pawn.origin);
|
|
43
|
+
*
|
|
44
|
+
* Returns true when the engine was called. The engine does not report whether the event has a
|
|
45
|
+
* parameter by that name, and it drops a write to one that doesn't exist. Returns false for any
|
|
46
|
+
* other value type, a non-finite number, or when the engine function did not resolve.
|
|
47
|
+
*/
|
|
48
|
+
setParam(name: string, value: number | Vector, opts?: SoundEventRecipients): boolean;
|
|
49
|
+
/** Stop this sound for the recipients. Returns false only when the engine function did not
|
|
50
|
+
* resolve. */
|
|
51
|
+
stop(opts?: SoundEventRecipients): boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
17
54
|
/** Block-scoped precache context — valid ONLY during the onPrecache dispatch. Synchronous use
|
|
18
55
|
* only: a stashed context used after the handler returns (or past an await) is a no-op `false`
|
|
19
56
|
* (the engine manifest is gone). */
|
|
@@ -52,6 +89,23 @@ export declare const Sound: {
|
|
|
52
89
|
* function / stale source entity / an empty `recipients` array). An all-bot-skipped recipient
|
|
53
90
|
* set still emits to nobody (a real engine call, may return a nonzero GUID). */
|
|
54
91
|
emit(name: string, opts?: SoundEmitOptions): number;
|
|
92
|
+
/** {@link Sound.emit}, keeping a handle so you can change the sound's parameters while it plays
|
|
93
|
+
* or stop that one instance. Returns null where `emit` would return 0. */
|
|
94
|
+
start(name: string, opts?: SoundEmitOptions): SoundEvent | null;
|
|
95
|
+
/**
|
|
96
|
+
* The length of a sound event in seconds, as the engine's sound event manager reports it.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const len = Sound.duration("MyPack.RoundMusic");
|
|
100
|
+
* if (len !== null) delay(len * 1000).then(() => Sound.emit("MyPack.RoundMusicEnd"));
|
|
101
|
+
*
|
|
102
|
+
* Returns null when the engine has no event by that name (check with {@link Sound.isValid}), or
|
|
103
|
+
* when the engine function did not resolve.
|
|
104
|
+
*/
|
|
105
|
+
duration(name: string): number | null;
|
|
106
|
+
/** Whether the engine knows a sound event by that name: a loaded soundevents file defines it.
|
|
107
|
+
* Returns false when the engine function did not resolve. */
|
|
108
|
+
isValid(name: string): boolean;
|
|
55
109
|
/**
|
|
56
110
|
* Stop a named SoundEvent playing on an entity — the counterpart to {@link Sound.emit}.
|
|
57
111
|
*
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @s2script/sdk/stringtables — the engine's network string tables. NO runtime code: the engine
|
|
3
|
+
* injects the implementation at load (`__s2pkg_stringtables`).
|
|
4
|
+
*
|
|
5
|
+
* String tables are how the server networks indexed strings to clients: precache lists, effect
|
|
6
|
+
* names, and per-entry user data. The engine rebuilds them on every map change, so a
|
|
7
|
+
* {@link StringTable} is plain data (its id and name) and every call looks the table up again. A
|
|
8
|
+
* handle kept past a map change answers -1 / null / false rather than reaching a freed table; get
|
|
9
|
+
* a fresh one with {@link StringTables.find}.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** A string table handle. Safe to keep: it holds no pointer. */
|
|
13
|
+
export interface StringTable {
|
|
14
|
+
/** The table's id, its position in the container. */
|
|
15
|
+
readonly id: number;
|
|
16
|
+
/** The table's name, for example `"EffectDispatch"`. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** How many strings the table holds, or -1 when the handle is stale. */
|
|
19
|
+
count(): number;
|
|
20
|
+
/** The index of `value` in the table, or -1 when it is absent or the handle is stale. */
|
|
21
|
+
findString(value: string): number;
|
|
22
|
+
/** The string at `index`, or null for an index out of range or a stale handle. */
|
|
23
|
+
getString(index: number): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* A copy of the user data stored with the string at `index`. An entry without user data gives an
|
|
26
|
+
* empty array; null means an index out of range or a stale handle.
|
|
27
|
+
*/
|
|
28
|
+
getData(index: number): Uint8Array | null;
|
|
29
|
+
/**
|
|
30
|
+
* Replace the user data of the string at `index`. A string is stored as its UTF-8 bytes. Returns
|
|
31
|
+
* false for an index out of range, a stale handle, or a value that is neither bytes nor a string.
|
|
32
|
+
*/
|
|
33
|
+
setData(index: number, data: Uint8Array | string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Add `value` to the table, with optional user data, and return its index. Adding a string the
|
|
36
|
+
* table already has returns its existing index. Returns -1 when the table is full or the handle
|
|
37
|
+
* is stale. The engine networks the new entry to clients.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const t = StringTables.find("EffectDispatch");
|
|
41
|
+
* const i = t?.addString("MyPack.Effect") ?? -1;
|
|
42
|
+
*/
|
|
43
|
+
addString(value: string, data?: Uint8Array | string): number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Find and list the server's string tables.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { StringTables } from "@s2script/sdk/stringtables";
|
|
51
|
+
* const effects = StringTables.find("EffectDispatch");
|
|
52
|
+
* const particle = effects?.findString("ParticleEffect") ?? -1;
|
|
53
|
+
*/
|
|
54
|
+
export declare const StringTables: {
|
|
55
|
+
/** The table with that name, or null. */
|
|
56
|
+
find(name: string): StringTable | null;
|
|
57
|
+
/** The table with that id, or null. */
|
|
58
|
+
get(id: number): StringTable | null;
|
|
59
|
+
/** How many tables the server has. 0 before the first map or when unavailable. */
|
|
60
|
+
count(): number;
|
|
61
|
+
/** Every table, in id order. */
|
|
62
|
+
all(): StringTable[];
|
|
63
|
+
};
|