The ruined streets of Boston beneath pre-war billboards
Fallout MPScripting

Build your
Commonwealth

Create your own game modes with TypeScript and JavaScript

02Scripting

If you can script it, the server can run it

Resources are plain TypeScript or JavaScript, loaded by the server and hot-reloaded while players stay connected. The API below is the one the mod itself is built on.

A command, in twenty lines

Drop a folder in the server’s resources, export a server entry point, and it loads on startup. Greet players as they arrive in the world and hand them a starter kit on request.

serverresources/welcome/src/server/index.ts
// Form IDs come from Fallout4.esm. Look yours up in the Creation Kit or xEdit.
const kStimpak = "0x00023736";

// playerConnect fires before the player has a position. Wait for playerReady to touch the world.
Events.on("playerReady", (player: Player) => {
  Chat.sendToPlayer(player, `Welcome to the Commonwealth, ${player.nickname}. Try /kit.`);
});

Events.on("playerCommand", (player: Player, command: string, args: string[]) => {
  if (command !== "kit") return;

  // Entity state is replicated and survives nothing but the session, which is all a kit flag needs
  if (player.state.get("kitTaken")) {
    Chat.sendToPlayer(player, "You have already taken a kit.");
    return;
  }

  const count = Math.min(Number(args[0] ?? 3) || 3, 10);
  player.giveItem(kStimpak, count);
  player.state.set("kitTaken", true);

  Chat.sendToPlayer(player, `${count} stimpaks. Do not spend them all in Concord.`);
});

02Reference

The whole server API

Generated from the running server, so this page and the mod cannot disagree. Every global, class, member and event the server exposes. Client resources have an API of their own, including the Web views that draw interfaces over the game.

34 globals and classes · 414 members · 49 native events

Events

Registered with Events.on(name, handler). The signature shown is the handler's argument list.

playerConnect(player: Player)
Dispatched once a connecting player's entity exists. It has no position yet; wait for `playerReady` to place them.
playerReady(player: Player)
Dispatched once the player's world is synced and they stand in it: the moment to spawn, dress and equip them. Their inventory record follows shortly after, with their first report.
playerDisconnect(player: Player)
Dispatched while a player is leaving, before their entity is destroyed, so the handle still reads. Anything keyed on the player is cleaned up here.
playerDeath(player: Player, killer: Player | null)
Dispatched once when a player dies. `killer` is the last player who hit them, or null. Nothing brings them back on its own: call `player.respawn`.
playerShoot(player: Player)
Dispatched when a player fires, before the shot is shown to the players around them.
playerProjectile(player: Player, projectile: number, npc: Npc | null)
Dispatched when a player's game launches a projectile: a missile, a grenade in flight, a flame, or one an NPC it simulates launched (`npc`). `projectile` is the BGSProjectile form ID. Return `false` to refuse: nobody else sees it. It still flies on the shooter's own screen.
playerSpaceChange(player: Player, space: PlayerSpace, previous: PlayerSpace | null)
Dispatched when a player's game reports them in another worldspace or interior: through a door, a fast travel or `teleport`. `previous` is null for the first space they report after joining.
playerAppearanceChange(player: Player)
Dispatched when a player's game reports a new look after the one they joined with: the look editor closed, or `setLook`, `randomizeLook` or `setAppearance` changed it. `getAppearance` reads it.
playerHit(attacker: Player, victim: Player, damage: number, kind: "direct" | "blast" | "hazard")
Dispatched when a player's game lands a hit on another player, before the victim takes it. Return `false` to drop the hit. `damage` is the attacker's game's own. `kind` is a shot or a blow, an explosion's blast, or a hazard the attacker left (a radiation or gas cloud), which casts its spell and carries no damage figure.
playerReload(player: Player, event: string)
Dispatched when a player starts a reload, before it is shown to the players around them. `event` is the animation event their game played.
playerExplosion(player: Player, position: Vector3, explosion: number, npc: number | null)
Dispatched when a player's game sets off an explosion: a grenade, a mine, a missile, an explosive round, or one an NPC it simulates set off (`npc`, its network ID). `explosion` is the BGSExplosion form ID. Return `false` to refuse it: nobody else sees it and its blast lands on no one.
playerPowerArmor(player: Player, entered: boolean)
Dispatched once when a player gets into a power armor frame (`entered`) and once when they get out, however it happened.
playerPowerArmorBattery(player: Player, charge: number, previous: number)
Dispatched when the charge of the fusion core in a player's power armor changes, in whole units: their game drains it (a jump, among others), a new core is loaded, or `setPowerArmorBattery` set it. Not on getting in.
playerFusionCore(player: Player, kind: "consumed" | "inserted" | "ejected", core: number | null, condition: number)
Dispatched when a player's game takes a fusion core into their power armor or launches it out. `consumed`: the suit's core ran out and their game loaded the next one they carry. `inserted`: a core went into the empty suit as it reached them. `ejected`: they launched the core out of the suit (Nuclear Physicist), `core` null. `condition` is the core's charge in percent. Return `false` to refuse a core taken in: it goes back to their inventory, the suit keeps the charge it had and takes no other core until `setPowerArmorBattery` gives it a charge or they get out. A launch cannot be refused.
playerChat(player: Player, text: string)
Dispatched for a chat line, before anyone sees it. Return `false` to swallow it.
playerCommand(player: Player, command: string, args: string[])
Dispatched for a `/command arg...` line; `command` has no slash.
worldHourChange(hour: number)
Dispatched when the running clock reaches a new whole hour, 0 to 23. `World.setHour` does not raise it.
doorChange(player: Player, ref: number, open: boolean)
Dispatched when a player opens or closes a door. Return `false` to refuse: their door swings back.
lockChange(player: Player, ref: number, locked: boolean)
Dispatched when a player picks, unlocks or locks a lock. Return `false` to refuse: their lock goes back.
containerOpen(player: Player, ref: number)
Dispatched when a player opens a container nobody else holds. Return `false` to keep it shut.
containerClose(player: Player, ref: number)
Dispatched when the player holding a container closes its menu; anyone may open it again.
containerChange(player: Player, ref: number, items: InventoryItem[])
Dispatched when a player's game reports what a container holds now, after they put something in or took something out. To refuse a transfer, refuse the player's `inventoryChange`, which reverts the container with it.
itemDrop(player: Player, item: Item)
Dispatched when a player drops an item. Return `false` to refuse: the item leaves the world and goes back into their inventory.
itemPickUp(player: Player, item: Item | null, ref: number | null)
Dispatched when a player picks up a loose item, before they get it: a dropped or spawned `item`, or a placed reference by its form ID as `ref`. Return `false` to refuse; the item stays where it is.
inventoryChange(player: Player, changes: InventoryDelta[])
Dispatched when a player's game reports a change the server would accept: looting, buying, crafting, using an item. Return `false` to refuse it: the server keeps its record and sends it back to their game, and any container involved keeps what it held. Changes a script made itself do not raise it.
playerCharacterLoad(player: Player)
Dispatched once a player's character is established, shortly after they join: adopted from their game. Restore a kept character here with `setCharacter`. Character methods work from here.
playerXpGain(player: Player, amount: number)
Dispatched when the player's game awards XP: a kill, a quest, a lock, a terminal, a workshop build. `amount` is the game's, Intelligence included. Return `false` to refuse it: their game takes it back.
playerLevelChange(player: Player, level: number, previous: number)
Dispatched when the character's level moves, by XP or by a script.
playerPerkRequest(player: Player, perk: number, kind: "buy" | "grant" | "remove")
Dispatched when the player's game changes a perk rank: bought on the perk chart (after the server checked points, level, the rank below and SPECIAL), given by something in the game such as a magazine, or taken away. Return `false` to refuse it: their game undoes it.
playerPerkChange(player: Player, perk: number, added: boolean)
Dispatched when a perk rank was added to or taken from the character, by their game or by a script.
playerValueRequest(player: Player, value: string, previous: number, base: number)
Dispatched when the player's game moves a SPECIAL base: the SPECIAL menu, a bobblehead, a book. `value` is its editor ID. Return `false` to refuse it: their game puts it back.
playerValueChange(player: Player, value: string, base: number, previous: number)
Dispatched when an actor value base on the character's record moved, by their game or by a script.
mineLaid(mine: Mine)
Dispatched once a player's mine settles and is armed. Return `false` to refuse: it leaves the world unexploded.
mineTrigger(mine: Mine, player: Player)
Dispatched when a player walks onto another player's mine, before it goes off. Return `false` to keep it armed; the player's game asks again every half second while they stand on it.
mineRemove(mine: Mine)
Dispatched when a mine goes, whatever took it: its blast, a disarm, its owner leaving or a script. The handle still reads.
npcHit(attacker: Player, npc: Npc, damage: number, kind: "direct" | "blast")
Dispatched when a player's game lands a hit on an NPC, before the NPC takes it. Return `false` to drop the hit. `damage` is the attacker's game's own; `kind` is a shot or a blow, or an explosion's blast.
npcAttack(npc: Npc, victim: Player, damage: number, kind: "direct" | "blast")
Dispatched when an NPC lands a hit on a player, before the victim takes it. Return `false` to drop the hit. `damage` is the game's own, from the client that runs the NPC.
npcDeath(npc: Npc, killer: Player | null)
Dispatched once when an NPC dies. `killer` is the last player who hit it, or null. It comes back on its own a while later; `npcRespawn` follows.
npcRespawn(npc: Npc)
Dispatched when an NPC is back at its placement, whole: on its own after its death, or from `respawn`.
npcSimulatorChange(npc: Npc, simulator: Player | null)
Dispatched when another player's game takes over running an NPC, or when nobody near does any more (`simulator` null) and the server walks it.
npcLeaderChange(npc: Npc, leader: Player | null)
Dispatched when an NPC becomes a player's companion (`setLeader`), or follows nobody any more (`leader` null): let go, or its leader left.
workshopBuild(player: Player, form: number, workbench: number, position: Vector3, angle: Vector3)
Dispatched when a player builds an object in a settlement, before anyone else sees it. Return `false` to refuse: their game takes it back out. The recipe's components are theirs to have spent; the server cannot refund them.
workshopMove(player: Player, item: WorkshopItem, position: Vector3, angle: Vector3)
Dispatched when a player moves a built object, before anyone else sees it. Return `false` to refuse: the object is put back where it was for everyone, as a new `WorkshopItem`, and the old handle reads nothing.
workshopScrap(player: Player, item: WorkshopItem)
Dispatched when a player scraps or stores a built object, before it goes for everyone. Return `false` to refuse: the object is put back for everyone, as a new `WorkshopItem`, and the old handle reads nothing. The player keeps what their game gave them for it.
resourceStart(resourceName: string)
Dispatched after a resource entry point has run and immediately before the resource becomes running.
resourceStop(resourceName: string)
Dispatched while a resource is stopping, before its stop callback, timers, exports and event handlers are cleaned up.
entityStateChange(entity: Entity, key: string, value: any, previous: any)
Dispatched when one key of an entity's state changes: on the server when a script writes it, on a client when the write arrives. `value` is undefined when the key was removed and `previous` is undefined when it held nothing before, so a stored null stays distinguishable from an absent key. The entity is whatever the game's WrapScriptEntity answers, and the base Entity handle by default.
consoleCommand(command: string, args: string[])
Dispatched for a line typed into the server console that no built-in command (help, ensure, refresh, ...) claimed. `args` is the rest of the line, split on whitespace. The console is the operator's, so this is the place for commands no player may run.
playerConnecting(connection: PendingConnection)
Dispatched when a player asks to join, before the connection exists: they hold no player slot, are not counted as online, and are sent nothing -- no resource list, no download, no body. The request waits until every handler has returned and every Promise a handler returned has settled, then it is let in if a player slot is free (otherwise it is refused as full). `connection.reject()` turns it away instead, and so does a handler that throws or rejects, or handlers that have not settled within the server's admission timeout (30 seconds by default, restarted by every `connection.update()`). With no handler at all, every request is let in at once.

Globals

Always in scope, in every resource. No imports.

Events

global

Asynchronous resource event bus.

Methods
on(eventName: string, handler: EventHandler): Unsubscribe

Registers a persistent handler in the shared event namespace.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.

Returns Function that removes this exact subscription.

once(eventName: string, handler: EventHandler)

Registers a handler that is removed before its first invocation.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
off(eventName: string, handler: EventHandler)

Removes a matching handler owned by the calling resource.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
emit(eventName: string, ...args: unknown[]): Promise<void>

Invokes every shared handler and waits for all synchronous and asynchronous results.

eventName
Shared event name.
args
Arguments delivered to every matching handler.

Returns Promise rejected with an AggregateError when one or more handlers fail.

emitTo(resourceName: string, eventName: string, ...args: unknown[]): Promise<void>

Invokes matching handlers belonging only to one resource.

resourceName
Destination running resource.
eventName
Shared event name.
args
Arguments delivered to matching handlers owned by the destination.

Returns Promise rejected when one or more destination handlers fail.

onLocal(eventName: string, handler: EventHandler)

Registers a handler in the calling resource's private local-event namespace.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
emitLocal(eventName: string, ...args: unknown[]): Promise<void>

Emits an event only within the calling resource.

eventName
Private local event name.
args
Arguments delivered only to handlers owned by the calling resource.

Returns Promise rejected when one or more local handlers fail.

listenerCount(eventName: string): number

Counts persistent and one-shot shared handlers across resources.

eventName
Shared event name to inspect.

Returns Number of matching handlers.

emitAllClients(eventName: string, payload?: unknown)

Broadcasts a named event to every connected client's shared Events handlers.

eventName
Client shared-event name.
payload
Optional string payload sent verbatim; other values are JSON-serialized.
onClient(eventName: string, handler: EventHandler): Unsubscribe

Registers a persistent server handler for events originating from clients; this namespace is isolated from native events.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.

Returns Function that removes this exact subscription.

onceClient(eventName: string, handler: EventHandler)

Registers a one-shot server handler for a client-originated event.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
offClient(eventName: string, handler: EventHandler)

Removes a matching client-originated event handler owned by the calling resource.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.

Chat

global

Server-side delivery of structured chat messages to connected clients.

Methods
sendToAll(text: string, options?: { author?: string; color?: number | Color })

Broadcasts a structured chat message to all clients.

text
Message body broadcast to every connected client.
options
Optional author label and color: a Color or a packed 0xRRGGBBAA integer.
sendToPlayer(player: Entity, text: string, options?: { author?: string; color?: number | Color })

Sends a structured chat message to one player's owning connection.

player
Player-owned entity identifying the destination connection.
text
Message body sent to the player.
options
Optional author label and color: a Color or a packed 0xRRGGBBAA integer.

World

global

The server's clock and weather, which every client follows.

Properties
hour: numberread-only

The hour of the day, from 0 up to but not including 24, with the minutes as the fraction: 13.5 is half past one.

timeScale: numberread-only

Game minutes per real minute. 20 is the game's own pace; 0 holds the clock.

weather: numberread-only

The TESWeather form ID every client shows.

weatherForced: booleanread-only

Whether the weather was swapped in at once rather than transitioned to.

Methods
setHour(hour: number)

Sets the clock. Every client jumps to it.

hour
The hour, wrapped into 0-24; 13.5 is half past one.
setTimeScale(scale: number)

Sets how fast the clock runs.

scale
Game minutes per real minute, 0 or more; 0 holds the clock.
setWeather(weather: number | string | null, force?: boolean)

Sets the weather every client shows. Only a client's data files can tell whether the form is a weather, so a wrong one leaves the sky as it is.

weather
A TESWeather form ID, as a number or hex string; null for the server's default, CommonwealthClear.
force
Swap it in at once rather than transition to it.

Objects

global

Doors, locks and containers, by the form ID of their placed reference. The server knows only what changed this session; the rest is as the data files place it, which only a client loads.

Methods
isDoorOpen(ref: number | string): boolean | null

Whether a door stands open.

ref
The placed reference's form ID.

Returns Null when nobody moved it this session.

isLocked(ref: number | string): boolean | null

Whether a door or container is locked.

ref
The placed reference's form ID.

Returns Null when nobody changed its lock this session.

setDoorOpen(ref: number | string, open: boolean)

Opens or closes a door for everyone, players who join later included.

ref
The placed reference's form ID.
open
Open or closed.
setLocked(ref: number | string, locked: boolean)

Locks or unlocks a door or container for everyone.

ref
The placed reference's form ID.
locked
Locked or not.
getContainer(ref: number | string): InventoryItem[] | null

What a container holds.

ref
The placed reference's form ID.

Returns Null until a player or a script set its contents this session; before that, each client rolls its own.

setContainer(ref: number | string, items: { form: number | string; count: number }[]): boolean

Fills a container for everyone.

ref
The placed reference's form ID.
items
Exactly what it should hold.

Returns False past 1024 kinds of item.

getContainerHolder(ref: number | string): Player | null

The player whose menu has a container open; nobody else can take from it meanwhile.

ref
The placed reference's form ID.

Returns Null when nobody holds it.

Voice

global

Server-side proximity voice rules: how far voice carries, and who may talk to or hear whom.

Methods
setRange(range: number)

Sets how far voice carries for talkers with no override of their own. Connected clients are told, so their playback fades out at the same distance.

range
Audibility radius in world units; values <= 0 restore the default of 25.
getRange(): number

Reads the server-wide proximity range.

Returns Radius in world units.

setPlayerRange(player: Entity, range: number)

Overrides how far one player's voice carries, whichever voice tier they chose.

player
Player whose voice carries the given distance.
range
Audibility radius in world units; values <= 0 return them to the radius of their voice tier.
getPlayerRange(player: Entity): number

Reads how far a player's voice carries, with the server-wide default already resolved.

player
Player to query.

Returns Radius in world units.

setTierRange(tier: number, range: number)

Sets how far a voice tier carries. Players switch tier themselves; whisper starts at 3, shout at 25, and normal carries the server-wide range. Set a tier to 0 to make it carry the server-wide range, which takes it away. Connected clients are told.

tier
Voice tier: 0 whisper, 1 normal, 2 shout.
range
Audibility radius in world units; values <= 0 make the tier carry the server-wide range.
getTierRange(tier: number): number

Reads how far a voice tier carries, with the server-wide range already resolved.

tier
Voice tier: 0 whisper, 1 normal, 2 shout.

Returns Radius in world units.

setPlayerTier(player: Entity, tier: number)

Puts a player on a voice tier, as if they had switched to it. Their own indicator follows, and the playerVoiceTierChange event is not raised.

player
Player to move.
tier
Voice tier: 0 whisper, 1 normal, 2 shout.
getPlayerTier(player: Entity): number

Reads the voice tier a player is on. A player switching tier raises the playerVoiceTierChange event with the player and the new tier.

player
Player to query.

Returns 0 whisper, 1 normal, 2 shout.

setPlayerMuted(player: Entity, muted: boolean)

Server-wide mute: a muted player's voice reaches nobody.

player
Player to mute or unmute.
muted
True to stop their voice reaching anyone.
isPlayerMuted(player: Entity): boolean

Checks the server-wide mute flag.

player
Player to query.

Returns True when the player's voice reaches nobody.

setPlayerDeaf(player: Entity, deaf: boolean)

Server-wide deafen: a deaf player receives nobody.

player
Player to deafen or undeafen.
deaf
True to stop them receiving anyone's voice.
isPlayerDeaf(player: Entity): boolean

Checks the server-wide deafen flag.

player
Player to query.

Returns True when the player receives nobody's voice.

setLocalMute(listener: Entity, target: Entity, muted: boolean)

One-way mute between two players, enforced by the server rather than the client.

listener
Player who stops hearing the target.
target
Player the listener stops hearing.
muted
True to mute, false to restore.
isLocallyMuted(listener: Entity, target: Entity): boolean

Checks a one-way mute.

listener
Player doing the muting.
target
Player being muted.

Returns True when the listener does not receive the target.

isPlayerVoiceEnabled(player: Entity): boolean

Checks whether a player left voice chat enabled in their own client settings. A preference, not a permission: use setPlayerMuted or setPlayerDeaf to enforce anything.

player
Player to query.

Returns True unless the player turned voice chat off.

isPlayerTalking(player: Entity): boolean

Checks whether a player is speaking right now. Tracks speech rather than the push-to-talk key: silence is dropped before it reaches the server, and the state clears shortly after the last frame. The same signal raises the playerVoiceStart and playerVoiceStop events.

player
Player to query.

Returns True while the player's voice is reaching the server.

Messages

global

Typed request and notification channel between local resources through the global Messages object.

Methods
handle(messageType: string, handler: MessageHandler)

Registers or replaces a message handler owned by the calling resource.

messageType
Message type unique within the receiving resource.
handler
Handler invoked with the payload and a reply callback; the reply is ignored for notifications.
request(resourceName: string, messageType: string, payload?: unknown): Promise<unknown>

Sends a request to another local resource and waits for its handler to call reply.

resourceName
Destination running resource.
messageType
Handler type registered by the destination.
payload
Optional payload delivered to the handler.

Returns Promise resolved with the reply value or rejected when delivery or handling fails.

send(resourceName: string, messageType: string, payload?: unknown)

Sends a fire-and-forget notification to another local resource.

resourceName
Destination running resource.
messageType
Handler type registered by the destination.
payload
Optional payload delivered to the handler.

Imports

global

Bulk access to values exported by another running resource through the global Imports object.

Methods
get(resourceName: string): Record<string, unknown>

Builds an object containing every currently registered export from another resource; undeclared dependencies produce a warning.

resourceName
Name of the running resource whose exports should be read.

Returns Object keyed by export name, or an empty object when the resource has no exports.

Exports

global

Registration and lookup of cross-resource values through the global Exports object.

Methods
register(name: string, value: unknown): boolean

Registers a value from the calling resource for use by dependent resources.

name
Export name, preferably declared in the current resource manifest.
value
JavaScript value or function retained by the current resource.

Returns True when the value was registered.

get(resourceName: string, exportName: string): unknown

Reads one registered export from another running resource; undeclared dependencies produce a warning.

resourceName
Name of the running resource that owns the export.
exportName
Registered export name.

Returns The exported value.

console

global

Resource-aware console that routes output through the Framework logger.

Methods
log(...values: unknown[])

Writes an informational log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
info(...values: unknown[])

Alias of console.log for informational output.

values
Values formatted and joined with spaces.
warn(...values: unknown[])

Writes a warning log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
error(...values: unknown[])

Writes an error log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
debug(...values: unknown[])

Writes a debug log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.

ExecutionEnvironment

global

Runtime-side flags exposed as the global ExecutionEnvironment.

Properties
isClient: booleanread-only

True in the sandboxed client scripting runtime.

isServer: booleanread-only

True in the authoritative server scripting runtime.

frameworkVersion: stringread-only

Local Framework release version.

modVersion: stringread-only

Local mod version from InstanceOptions.modVersion; empty when unset.

Players and entities

What the server hands your event handlers.

Player

classextends BasePlayer

A connected player and the character they control. Their own game decides their body: what a getter reads is their last report, and a setter is a request their game carries out, then reports back.

Constructor
new Player(id: number)

Wraps an already connected player with this ID; it neither connects nor spawns anyone.

id
Network entity identifier.
Properties
nickname: stringread-only

The name the player connected with. Empty once they are gone.

health: number

Current health, as the player's game last reported it. Assigning asks their game to move it there, as `setValue("Health", value)` does; it reads the new value once they report it.

maxHealth: numberread-only

Health at full.

armor: numberread-only

Damage resistance from the armor the player wears.

isDead: booleanread-only

Whether the player is dead. A dead player stays down until `respawn`.

isFemale: booleanread-only

Whether the character is female.

heading: numberread-only

Facing, in radians around Z.

aimPitch: numberread-only

Aim pitch, in radians.

velocity: Vector3read-only

Velocity, in game units per second.

isSneaking: booleanread-only

Whether the player sneaks.

isJumping: booleanread-only

Whether the player is in the air from a jump.

isSprinting: booleanread-only

Whether the player sprints.

isRunning: booleanread-only

Whether the player runs rather than walks.

isWeaponDrawn: booleanread-only

Whether the player's weapon is out.

isAiming: booleanread-only

Whether the player aims down the sights of a drawn gun.

isPipBoyOpen: booleanread-only

Whether the player's Pip-Boy is up.

isInPowerArmor: booleanread-only

Whether the player wears a power armor frame.

Methods
exitPowerArmor(): boolean

Takes the player out of their power armor; the frame stays where they stand. `playerPowerArmor` follows once their game is done, which it is not while they fly the fly camera (`NoClip`): the game leaves the player's own update alone until the camera comes back.

Returns True when sent; false when the player is gone or not in power armor.

kill(): boolean

Kills the player through their game's own hit path; `playerDeath` follows with a null killer.

Returns True when sent; false when the player is gone or already dead.

openLookEditor(): boolean

Opens the character look editor on the player's screen.

Returns True when sent; false when the player is gone.

stopIdle(): boolean

Stops the idle animation the player plays and returns them to their stance.

Returns True when sent; false when the player is gone.

toString(): string

Formats this handle for logging.

Returns The player's network ID and nickname.

teleport(position: Vector3, heading?: number, space?: { worldSpace?: number | string; interiorCell?: number | string }): boolean

Moves the player, within their space or into another one. Into an interior they land at a persistent reference inside it, as a quest script moves the player, and `position` is not used: wait for `playerSpaceChange`, then teleport them within it. `playerSpaceChange` follows any change of space.

position
Where to, in the space the player goes to.
heading
Facing in radians; the current one when left out.
space
Another worldspace or an interior cell, exactly one of the two; the one the player is in when left out.

Returns True when sent; false when the player is gone, or the interior has no reference to land at. Throws for a position that is not a finite Vector3.

respawn(position?: Vector3, heading?: number): boolean

Brings a dead player back at full health. Nothing respawns a player on its own: call this from `playerDeath`, at once or later.

position
Where to come back; where the player fell when left out.
heading
Facing in radians; the one they died with when left out.

Returns True when sent; false when the player is gone or alive.

fire(shots?: number): boolean

Has the player's game fire its drawn weapon.

shots
How many times, 1 to 255; once when left out.

Returns True when sent; false when the player is gone.

enterPowerArmor(frame?: number | string): boolean

Places a power armor frame where the player stands and puts them into it at once, as `Actor.SwitchToPowerArmor` does. `playerPowerArmor` follows. The suit's pieces are the frame's; dress them with `setOutfit`.

frame
The TESFurniture of the frame to place; the game's empty frame when left out.

Returns True when sent; false when the player is gone or already in power armor.

setPowerArmorBattery(charge: number): boolean

Sets the charge of the fusion core in the player's power armor, through the value their game drains. At 0 their game does what it does with an empty core: it loads the next fusion core they carry, or leaves the suit unpowered. Above the core's capacity the capacity follows. It also lifts the hold a refused core left the suit in. `playerPowerArmorBattery` follows.

charge
The charge to leave in the core, 0 to 1000; a full fusion core holds 100.

Returns True when sent; false when the player is gone or not in power armor.

getPowerArmor(): PlayerPowerArmor | null

The power armor frame the player wears.

Returns The frame, or null when they wear none or are gone.

getSpace(): PlayerSpace | null

Where the player is.

Returns The worldspace or interior cell, or null when the player is gone.

getWeapon(): PlayerWeapon | null

The weapon in the player's hands.

Returns The weapon, or null when they have none or are gone.

getOutfit(): OutfitPiece[]

What the player wears.

Returns One entry per armor piece; empty when the player is gone.

setOutfit(pieces: (number | string | { form: number | string; mods?: (number | string)[] })[], mode?: "replace" | "add" | "remove"): boolean

Dresses the player. Pieces the player's game cannot wear are skipped there.

pieces
Armor form IDs, or objects naming the mods to attach. Up to 32 pieces of 8 mods.
mode
`replace`, the default, wears exactly these and takes every other piece off; `add` puts them on over what is worn; `remove` takes them off.

Returns True when sent; false when the player is gone.

randomizeOutfit(seed?: number): boolean

Dresses the player in a random playable outfit, mods included.

seed
Rolls the same outfit for the same seed; a fresh one when left out.

Returns True when sent; false when the player is gone.

setLook(look: { female?: boolean; skinTone?: { r: number; g: number; b: number }; hair?: number | string }): boolean

Changes the character's look; the player's game rebuilds them and everyone sees it.

look
What to change: the sex, the skin tone in 0-255 channels, a hair BGSHeadPart. What is left out stays.

Returns True when sent; false when the player is gone.

randomizeLook(seed?: number, morphsOnly?: boolean): boolean

Rolls the character a new look from their race's character generation data.

seed
Rolls the same look for the same seed; a fresh one when left out.
morphsOnly
Only the face sliders and regions, keeping sex, hair and colours.

Returns True when sent; false when the player is gone.

getAppearance(): string | null

The player's whole look as their game last reported it, as an opaque string to keep (a database column) and hand back to `setAppearance`.

Returns Null before their first report or once they are gone.

setAppearance(look: string): boolean

Puts a whole look back on the player: their game rebuilds them and everyone sees it. Throws for a look from another server version.

look
As `getAppearance` returned it on this server version.

Returns True when sent; false when the player is gone.

setGameName(name: string): boolean

Names the player's character in their own game, as the Vault 111 registration form does: what the game's menus show, and what the SPECIAL menu requires before it closes. Others see the nametag, not this.

name
1 to 64 characters.

Returns True when sent; false when the player is gone.

getInventory(): InventoryItem[]

What the player carries, from the server's record.

Returns One entry per base object and condition; empty before the player's first report, shortly after they join, and once they are gone.

getItemCount(form: number | string): number

How many of an item the player carries.

form
The base object.

Returns The count; 0 when they carry none or are gone.

giveItem(form: number | string, count?: number, condition?: number): boolean

Puts items in the player's inventory. It does not equip them: see `equipItem`.

form
The base object.
count
How many, 1 to 1000000; one when left out.
condition
Their condition in percent of full, 0 to 100, as one stack: a fusion core's charge. Full when left out.

Returns True when the record changed; false before the player's first report or once they are gone.

removeItem(form: number | string, count?: number, condition?: number): boolean

Takes items out of the player's inventory.

form
The base object.
count
How many, 1 to 1000000; one when left out. More than they carry takes them all.
condition
The condition to take first, 0 to 100; the rest come from the fullest stacks. Full when left out.

Returns True when the record changed; false before the player's first report or once they are gone.

setItemCount(form: number | string, count: number): boolean

Sets how many of an item the player carries, over every condition: more are added at full condition, fewer are taken from full stacks first.

form
The base object.
count
How many the player should carry, 0 to 1000000.

Returns True when the record changed; false before the player's first report or once they are gone.

equipItem(form: number | string): boolean

Has the player draw a weapon or wear an armor piece they carry. Right after `giveItem` it lands too: the inventory reaches their game first.

form
A weapon or armor piece the player carries.

Returns True when sent; false when the server's record has none of it or the player is gone.

playIdle(idle: string | number): boolean

Plays an idle animation on the player, as `Actor.PlayIdle` does; everyone around them sees it. The idle's own conditions apply, so one meant for another skeleton, a piece of furniture or a state the player is not in does nothing. Moving ends most idles; `stopIdle` ends any.

idle
An idle animation from the game's data (an IDLE record): its editor ID, such as `"Salute"`, or its form ID.

Returns True when sent; false when the player is gone. Throws for a name or form ID no IDLE record has.

getValue(value: string | number): number | null

An actor value as it stands: Health, ActionPoints and Rads as the player's game last reported them, any other the base the record holds.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.

Returns The value; null before the character is established or for a value the record does not hold.

getBaseValue(value: string | number): number | null

The base the character's record holds for an actor value: SPECIAL, Experience, and any base a script set.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.

Returns The base; null for one the record does not hold.

setBaseValue(value: string | number, base: number): boolean

Sets an actor value's base on the record and in the player's game, as `ObjectReference.SetValue` does: for Health or CarryWeight that is the maximum. It is saved with the character and set again whenever they join.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
base
The new base. SPECIAL is rounded and kept within 1 to 11.

Returns True when the record changed; false before the character is established.

damageValue(value: string | number, amount: number): boolean

Lowers an actor value's current value in the player's game, as `ObjectReference.DamageValue` does. Health damaged to 0 kills.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
amount
How much, at least 0. Rads rise by it.

Returns True when sent; false when the player is gone.

restoreValue(value: string | number, amount: number): boolean

Raises an actor value's current value in the player's game up to its maximum, as `ObjectReference.RestoreValue` does.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
amount
How much, at least 0. Rads fall by it.

Returns True when sent; false when the player is gone.

setValue(value: string | number, current: number): boolean

Moves an actor value's current value in the player's game, keeping its base.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
current
The current value to reach; no higher than the maximum.

Returns True when sent; false when the player is gone.

getLevel(): number

The character's level.

Returns The level; 0 when the player is gone.

setLevel(level: number): boolean

Sets the character's level and their XP to the start of it. No perk points come with it: see `setPerkPoints`.

level
1 to 65535.

Returns True when the record changed; false before the character is established.

getXp(): number

The character's total experience.

Returns The XP; 0 when the player is gone.

setXp(xp: number): boolean

Sets the character's total experience, and their level to match. No perk points come with it.

xp
The total, at least 0.

Returns True when the record changed; false before the character is established.

addXp(amount: number): boolean

Awards experience as the game does: each level it reaches brings a perk point and the game's level-up.

amount
More than 0. Not scaled by Intelligence.

Returns True when the record changed; false before the character is established.

getPerkPoints(): number

The character's unspent perk points.

Returns The points; 0 when the player is gone.

setPerkPoints(points: number): boolean

Sets the character's unspent perk points.

points
0 to 255.

Returns True when the record changed; false before the character is established.

getPerks(): number[]

The perk ranks the character holds. Each rank of a perk is a BGSPerk of its own.

Returns Their form IDs; empty when the player is gone.

hasPerk(perk: number | string): boolean

Whether the character holds a perk rank.

perk
A BGSPerk rank.

Returns True when they hold it. Throws for a form ID that is no perk.

addPerk(perk: number | string, withLowerRanks?: boolean): boolean

Gives the character a perk rank without spending a point.

perk
A BGSPerk rank.
withLowerRanks
Also give the ranks below it; true when left out.

Returns True when the record changed; false before the character is established. Throws for a form ID that is no perk.

removePerk(perk: number | string): boolean

Takes a perk rank from the character, and every rank above it. No point is refunded.

perk
A BGSPerk rank.

Returns True when the record changed; false when they do not hold it.

getCaps(): number

The bottle caps the player carries: the Caps001 item in the inventory record.

Returns The count; 0 before the first inventory report or once they are gone.

setCaps(caps: number): boolean

Sets the bottle caps the player carries.

caps
0 to 1000000.

Returns True when the record changed; false before the first inventory report.

openSpecialMenu(): boolean

Opens the game's SPECIAL allocation menu on the player's screen, as the Vault 111 exit does. Each point they move comes back as `playerValueRequest`.

Returns True when sent; false when the player is gone.

openPerkChart(): boolean

Opens the game's perk chart on the player's screen. Each rank bought comes back as `playerPerkRequest`.

Returns True when sent; false when the player is gone.

getCharacter(): CharacterDocument | null

The whole character: experience, level, perk points, bases, perks, current values and inventory. Keep it wherever the gamemode likes; `setCharacter` takes it back.

Returns The document; null before the character is established.

setCharacter(character: Partial<CharacterDocument>): boolean

Replaces the character with a document, and brings the player's game to it.

character
As `getCharacter` returns it. What it leaves out stays as it is.

Returns True when applied; false before the character is established. Throws for a malformed document.

static xpForLevel(level: number): number

The total experience a level starts at, by the game's formula.

level
1 to 65535.

Returns The XP.

static all(): Player[]

Every connected player.

Returns One handle per player, in no particular order.

static getById(id: number): Player | null

Looks a player up by network ID.

id
Network entity identifier.

Returns The handle, or null when no connected player has that ID.

BasePlayer

classextends Entity

Framework-owned base handle for a connected player, extended by each game or mod.

Constructor
new BasePlayer(id: number)

Creates a wrapper for an existing connected player with this ID; it does not connect or spawn a player.

id
Network entity identifier.
Properties
steamId: stringread-only

Authenticated Steam identifier, or an empty string when unavailable.

epicId: stringread-only

Epic Games account identifier the client reported, not verified by the server, or an empty string when unavailable.

discordId: stringread-only

Authenticated Discord identifier, or an empty string when unavailable.

hardwareId: stringread-only

Framework hardware identifier, or an empty string when unavailable.

ping: numberread-only

Current round-trip latency in milliseconds, or -1 when unavailable.

ip: stringread-only

Current remote network address, or an empty string when unavailable.

Methods
toString(): string

Formats this player handle for logging and debugging.

Returns Text containing the player's network entity ID.

isNametagVisible(): boolean

Checks whether this player's nametag is shown to other players.

Returns True unless the nametag was hidden; false also when this game has no nametags.

isNametagHealthVisible(): boolean

Checks whether the health bar under this player's nametag is shown.

Returns True unless the health bar was hidden; false also when this game has no nametags.

getNametagText(): string

Reads this player's nametag text override.

Returns The override, or an empty string when the player's own name is drawn.

getNametagColor(): number

Reads this player's nametag color.

Returns Packed 0xAARRGGBB color; opaque white when untinted.

kick(reason?: string)

Disconnects this player from the server.

reason
Optional reason shown to the disconnected player; omitting it uses the generic kicked reason.
emit(eventName: string, payloadJson?: string)

Emits a named script event to this player's client connection.

eventName
Client event name.
payloadJson
Optional JSON payload forwarded verbatim to the owning client.
getIP(): string

Returns this player's current remote network address.

Returns Address string, or an empty string when the player or peer is unavailable.

setNametagVisible(visible: boolean)

Shows or hides the name over this player's head for every other player. The health bar has its own switch, and each player can still hide all nametags locally.

visible
True to show this player's nametag to everyone, false to hide it.
setNametagHealthVisible(visible: boolean)

Shows or hides the health bar under this player's nametag, leaving the name itself alone.

visible
True to show the health bar under this player's name, false to hide it.
setNametagText(text?: string)

Overrides the text drawn on this player's nametag.

text
Text to show instead of the player's name, cut to 64 bytes; empty or omitted restores the name.
setNametagColor(color: number)

Tints the text on this player's nametag.

color
Packed 0xAARRGGBB color.

Entity

class

Base handle for a live replicated network entity.

Constructor
new Entity(id: number)

Creates a script wrapper for an existing entity with this ID; it does not spawn an entity.

id
Network entity identifier.
Properties
id: numberread-only

Immutable network entity identifier.

virtualWorld: numberread-only

Current virtual-world identifier.

position: Vector3

Authoritative world-space position; assignment forces replicated state.

rotation: Quaternion | Vector3

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

state: StateBagread-only

Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.

Methods
toString(): string

Formats this entity handle for logging and debugging.

Returns Text containing the network entity ID.

setVirtualWorld(world: number)

Moves this entity into another virtual world.

world
Virtual-world identifier used to partition replication and visibility.
setVisibleTo(player: Entity | null)

Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.

player
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

Item

classextends Entity

A loose item in the world: one a player dropped or a script spawned. Picking it up destroys it, after which the handle reads nothing. Setting `position` moves it for everyone.

Constructor
new Item(id: number)

Wraps an existing item with this ID; it spawns nothing. See `Item.spawn`.

id
Network entity identifier.
Properties
form: numberread-only

The base object's form ID; 0 once it is gone.

count: numberread-only

How many the stack holds; 0 once it is gone.

Methods
destroy(): boolean

Takes the item out of the world for everyone.

Returns True when it was there to take.

toString(): string

Formats this handle for logging.

Returns The item's network ID, form and count.

getSpace(): PlayerSpace | null

Where the item lies.

Returns The worldspace or interior cell, or null once it is gone.

static spawn(form: number | string, count: number, position: Vector3, space: { worldSpace?: number | string; interiorCell?: number | string }, angle?: Vector3): Item | null

Puts a loose item in the world, which any player can pick up. It does not fall: it stays where it is put.

form
The base object.
count
How many, 1 to 1000000.
position
Where it lies.
space
The worldspace, or the interior cell: exactly one of the two.
angle
Its rotation, radians.

Returns The item, or null when it could not be created.

static all(): Item[]

Every loose item in the world.

Returns One handle per item.

StateBag

class

Arbitrary key/value state attached to one replicated entity, reached as `entity.state`. Keys set on the server replicate to every client that can currently see the entity.

Methods
get(key: string): any

Reads one key from this entity's state.

key
Key to read.

Returns The stored value, or undefined when the key is not set.

has(key: string): boolean

Checks whether this entity's state holds a key.

key
Key to test.

Returns True when the key is set.

keys(): string[]

Lists the keys this entity's state holds, sorted.

Returns Every key currently set, in ascending order.

toObject(): Record<string, any>

Copies this entity's whole state into a plain object.

Returns Every key and value currently set. The copy does not track later changes.

onChange(key: string | null, handler: Function): Function

Watches this entity's state. The filter is applied before the handler runs, so a listener watching one key of one entity is not woken by unrelated changes. The subscription is dropped when the registering resource stops.

key
Only report this key, or null to report every key of this entity.
handler
Called as (key: string, value: any, previous: any) with the changed key, its new value and the value before it. `value` is undefined when the key was removed and `previous` is undefined when it held nothing.

Returns A zero-argument function that cancels this subscription.

set(key: string, value: any, options?: { scope?: 'broadcast' | 'owner' | 'server' }): boolean

Writes one key of this entity's state and replicates it to whoever the scope names. Throws when a limit is reached.

key
Key to write; at most 64 UTF-8 bytes.
value
Value to store. Booleans, numbers and strings travel as themselves; anything else is serialized as JSON. At most 4096 bytes.
options
Who the key reaches: every client that can see the entity (the default), only its owning client, or nobody -- server-side storage that never goes on the wire.

Returns True when the value changed, false when it was already stored.

remove(key: string): boolean

Removes one key from this entity's state, telling every client that held it.

key
Key to drop.

Returns True when the key was set and has been removed.

PendingConnection

type

A player asking to join, handed to `playerConnecting`. Every identifier is reported by the player's own client and is not verified by the server.

Properties
nickname: stringread-only

The name the player asked to join under.

steamId: stringread-only

Steam identifier the client reported, or an empty string when it had none.

epicId: stringread-only

Epic Games account identifier the client reported, or an empty string when it had none.

discordId: stringread-only

Discord identifier the client reported, or an empty string when it had none.

hardwareId: stringread-only

Framework hardware identifier the client reported, or an empty string when it had none.

ticket: stringread-only

The string the client was launched with, as the `ticket` of its launch link, or an empty string. The framework passes it through untouched; checking it -- against a one-time join ticket your own launcher or website issued, typically -- is the script's job.

ip: stringread-only

The remote address the connection comes from, without its port.

Methods
reject(reason?: string)

Turns the player away before they receive anything. Takes effect on the next server tick, whatever other handlers are still doing. Does nothing once the connection is decided or the player has left.

reason
Shown to the player as written, up to 512 bytes. Omitted, they read that the server refused the connection.
update(message: string)

Shows the waiting player a line of status and restarts the admission timeout, so a queue that keeps updating its players is never timed out. Does nothing once the connection is decided or the player has left.

message
One line for the player's connecting screen, up to 256 bytes: 'Checking the whitelist', 'You are 4th in the queue'.
isPending(): boolean

Checks whether this connection is still waiting on a decision.

Returns False once it was let in or turned away, or the player gave up and left; a queue drops such entries.

Maths and colour

Positions, rotations and colours, with the operators you expect.

Vector2

class

Mutable two-dimensional vector.

Constructor
new Vector2(x: number, y: number)

Creates a vector from two numeric components.

x
Initial X component.
y
Initial Y component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector2): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector2): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to both components.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to both components; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector2): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector2, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number): this

Replaces both components in place.

x
Replacement X component.
y
Replacement Y component.

Returns This mutated vector for chaining.

distance(other: Vector2): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

clone(): Vector2

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector2(x, y) form.

toJSON(): { x: number; y: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector2

Creates a vector whose components are zero.

Returns New Vector2(0, 0).

static one(): Vector2

Creates a vector whose components are one.

Returns New Vector2(1, 1).

Vector3

class

Mutable three-dimensional vector for positions, directions, and Euler angles.

Constructor
new Vector3(x: number, y: number, z: number)

Creates a vector from three numeric components.

x
Initial X component.
y
Initial Y component.
z
Initial Z component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

z: number

Mutable Z component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector3): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector3): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to every component.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to every component; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector3): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

cross(other: Vector3): this

Replaces this vector with its cross product against another vector.

other
Second vector in the cross product.

Returns This mutated perpendicular vector for chaining.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector3, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number, z: number): this

Replaces all components in place.

x
Replacement X component.
y
Replacement Y component.
z
Replacement Z component.

Returns This mutated vector for chaining.

distance(other: Vector3): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

clone(): Vector3

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector3(x, y, z) form.

toJSON(): { x: number; y: number; z: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector3

Creates a zero vector.

Returns New Vector3(0, 0, 0).

static one(): Vector3

Creates a vector whose components are one.

Returns New Vector3(1, 1, 1).

static up(): Vector3

Creates the framework's positive-Y unit direction.

Returns New Vector3(0, 1, 0).

static forward(): Vector3

Creates the framework's positive-Z unit direction.

Returns New Vector3(0, 0, 1).

static right(): Vector3

Creates the framework's positive-X unit direction.

Returns New Vector3(1, 0, 0).

Vector4

class

Mutable four-dimensional vector.

Constructor
new Vector4(x: number, y: number, z: number, w: number)

Creates a vector from four numeric components.

x
Initial X component.
y
Initial Y component.
z
Initial Z component.
w
Initial W component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

z: number

Mutable Z component.

w: number

Mutable W component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector4): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector4): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to every component.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to every component; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector4): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

distance(other: Vector4): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector4, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number, z: number, w: number): this

Replaces all components in place.

x
Replacement X component.
y
Replacement Y component.
z
Replacement Z component.
w
Replacement W component.

Returns This mutated vector for chaining.

clone(): Vector4

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector4(x, y, z, w) form.

toJSON(): { x: number; y: number; z: number; w: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector4

Creates a zero vector.

Returns New Vector4(0, 0, 0, 0).

static one(): Vector4

Creates a vector whose components are one.

Returns New Vector4(1, 1, 1, 1).

Quaternion

class

Mutable quaternion for three-dimensional rotations. Components are scalar-first (w, x, y, z), matching GLM — not the x, y, z, w order some libraries use.

Constructor
new Quaternion(w: number, x: number, y: number, z: number)

Creates a quaternion in scalar-first w, x, y, z component order. Watch the trap: the scalar w is the first argument, unlike the x, y, z, w order used by some other libraries.

w
Initial scalar component (comes first — this is not x, y, z, w order).
x
Initial X imaginary component.
y
Initial Y imaginary component.
z
Initial Z imaginary component.
Properties
w: number

Mutable scalar component.

x: number

Mutable X imaginary component.

y: number

Mutable Y imaginary component.

z: number

Mutable Z imaginary component.

length: numberread-only

Read-only magnitude (norm) of this quaternion; 1 for a unit rotation.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
mul(other: Quaternion): this

Composes this rotation with another quaternion in place.

other
Rotation composed after this quaternion.

Returns This mutated quaternion for chaining.

normalize(): this

Normalizes this quaternion in place; a zero quaternion becomes the identity rotation instead of NaN.

Returns This unit quaternion for chaining.

conjugate(): Quaternion

Computes the conjugate without changing this quaternion.

Returns New conjugated quaternion.

inverse(): Quaternion

Computes the inverse rotation without changing this quaternion.

Returns New inverse quaternion.

slerp(target: Quaternion, t: number): this

Spherically interpolates this quaternion toward a target in place.

target
Destination rotation.
t
Interpolation factor; 0 keeps the current rotation and 1 reaches target.

Returns This mutated quaternion for chaining.

dot(other: Quaternion): number

Computes the quaternion dot product.

other
Quaternion used for the dot product.

Returns Scalar dot product.

rotateVector(vector: Vector3): Vector3

Applies this rotation to a vector without mutating either value.

vector
Vector to rotate.

Returns New rotated vector.

toEuler(): Vector3

Converts this rotation to Euler angles in radians.

Returns Pitch, yaw, and roll as a Vector3.

set(w: number, x: number, y: number, z: number): this

Replaces all quaternion components in place.

w
Replacement scalar component.
x
Replacement X imaginary component.
y
Replacement Y imaginary component.
z
Replacement Z imaginary component.

Returns This mutated quaternion for chaining.

clone(): Quaternion

Creates an independent copy of this quaternion.

Returns New quaternion with the same components.

toString(): string

Formats this quaternion for logging and debugging.

Returns Text in Quaternion(w, x, y, z) form.

toJSON(): { w: number; x: number; y: number; z: number }

Converts this quaternion to a plain object for JSON.stringify.

Returns Object containing the current components.

static identity(): Quaternion

Creates the identity rotation.

Returns New Quaternion(1, 0, 0, 0).

static fromEuler(pitch: number, yaw: number, roll: number): Quaternion

Creates a rotation from Euler angles.

pitch
Pitch angle in radians.
yaw
Yaw angle in radians.
roll
Roll angle in radians.

Returns New rotation quaternion.

static fromAxisAngle(axis: Vector3, angle: number): Quaternion

Creates a rotation around an axis.

axis
Rotation axis; it is normalized internally.
angle
Rotation angle in radians.

Returns New axis-angle rotation quaternion.

Color

class

Mutable RGBA color, with components stored from 0 to 1.

Constructor
new Color(r: number, g: number, b: number, a?: number)

Creates a color from normalized RGBA components.

r
Initial red component from 0 to 1.
g
Initial green component from 0 to 1.
b
Initial blue component from 0 to 1.
a
Optional alpha component from 0 to 1; defaults to 1.
Properties
r: number

Mutable normalized red component.

g: number

Mutable normalized green component.

b: number

Mutable normalized blue component.

a: number

Mutable normalized alpha component.

Methods
lerp(target: Color, t: number): this

Linearly interpolates every component toward a target in place.

target
Destination color.
t
Interpolation factor; 0 keeps this color and 1 reaches target.

Returns This mutated color for chaining.

set(r: number, g: number, b: number, a?: number): this

Replaces this color's normalized components in place.

r
Replacement red component from 0 to 1.
g
Replacement green component from 0 to 1.
b
Replacement blue component from 0 to 1.
a
Optional replacement alpha; defaults to 1 when omitted.

Returns This mutated color for chaining.

clone(): Color

Creates an independent copy of this color.

Returns New color with the same components.

toHex(includeAlpha?: boolean): string

Converts normalized components to a hexadecimal CSS-style string.

includeAlpha
Whether to append the alpha byte; defaults to false.

Returns Lowercase #rrggbb or #rrggbbaa string.

toString(): string

Formats this color for logging and debugging.

Returns Text in Color(r, g, b, a) form.

toJSON(): { r: number; g: number; b: number; a: number }

Converts this color to a plain object for JSON.stringify.

Returns Object containing the current normalized components.

static fromHex(hex: string): Color

Parses a hexadecimal color string.

hex
Hexadecimal color in #RRGGBB or #RRGGBBAA form; the leading # is optional. Three- and four-digit shorthands are not supported.

Returns Parsed color, or opaque white when the input is invalid.

static fromRGB(r: number, g: number, b: number, a?: number): Color

Creates a normalized color from byte components.

r
Red byte from 0 to 255.
g
Green byte from 0 to 255.
b
Blue byte from 0 to 255.
a
Optional alpha byte from 0 to 255; defaults to 255.

Returns New normalized color.

static white(): Color

Creates opaque white.

Returns New Color(1, 1, 1, 1).

static black(): Color

Creates opaque black.

Returns New Color(0, 0, 0, 1).

static red(): Color

Creates opaque red.

Returns New Color(1, 0, 0, 1).

static green(): Color

Creates opaque green.

Returns New Color(0, 1, 0, 1).

static blue(): Color

Creates opaque blue.

Returns New Color(0, 0, 1, 1).

static yellow(): Color

Creates opaque yellow.

Returns New Color(1, 1, 0, 1).

static cyan(): Color

Creates opaque cyan.

Returns New Color(0, 1, 1, 1).

static magenta(): Color

Creates opaque magenta.

Returns New Color(1, 0, 1, 1).

static transparent(): Color

Creates fully transparent black.

Returns New Color(0, 0, 0, 0).

Other types

The structural types the API passes around.

PlayerSpace

type

Where a player is: the worldspace it stands in, or the interior cell, which has none.

Properties
worldSpace: number

The TESWorldSpace form ID; 0 inside an interior.

interiorCell: number

The interior TESObjectCELL form ID; 0 outside.

PlayerWeapon

type

The weapon in a player's hands, drawn or holstered.

Properties
form: number

The TESObjectWEAP form ID.

ammo: number

The ammo form ID it loads; 0 for none.

mods: number[]

The OMOD form IDs attached to it.

OutfitPiece

type

One armor piece a player wears, with the mods attached to it.

Properties
form: number

The TESObjectARMO form ID.

mods: number[]

The OMOD form IDs attached to it.

PlayerPowerArmor

type

The power armor frame a player wears.

Properties
frame: number | null

The frame's reference form ID when the data files placed it; null for one the game created at runtime.

base: number | null

The frame's TESFurniture form ID; null when the game created that record at runtime.

battery: number

The charge left in the inserted fusion core, in whole units rounded up; 0 when it is empty or there is none.

batteryMax: number

The inserted fusion core's capacity, 100 for the game's own; 0 while none was ever inserted.

InventoryItem

type

A stack in a player's inventory, as the server's record holds it.

Properties
form: number

The base object's form ID.

count: number

How many the player carries.

condition: number

The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.

InventoryDelta

type

How many of one item a player's inventory gained or lost.

Properties
form: number

The base object's form ID.

delta: number

Gained when positive, lost when negative.

condition: number

The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.

from: number | null

The reference on the other side, such as a container; null for none the game named.

CharacterDocument

type

A whole character, as getCharacter gives it and setCharacter takes it. Actor values are keyed by editor ID; forms are hex strings.

Properties
version: number

The document's format, 1.

nickname: string

The nickname of the player it was taken from.

experience: number

Total XP.

level: number

The level.

perkPoints: number

Unspent perk points.

values: Record<string, number>

Actor value bases: SPECIAL and any a script set.

perks: string[]

The BGSPerk ranks held.

current: Record<string, number>

Health, ActionPoints and Rads as they stood.

inventory: { form: string; count: number }[]

What the character carries.

Mine

classextends Entity

An armed mine a player laid. Its owner's game holds the mine and sets it off; the server decides when. Once it goes off or is removed the handle reads nothing. Mines go with their owner when they leave.

Constructor
new Mine(id: number)

Wraps an armed mine with this ID; it lays nothing.

id
Network entity identifier.
Properties
radius: numberread-only

How close a player must come to set it off, in game units; 0 once it is gone.

explosion: numberread-only

The BGSExplosion form ID it sets off; 0 once it is gone.

Methods
detonate(): boolean

Has the owner's game set the mine off where it lies, as if a player walked onto it. The blast is the owner's: `playerExplosion` and `playerHit` follow.

Returns True when sent; false when it is gone or already going off.

remove(): boolean

Takes the mine out of the world without a blast.

Returns True when it was armed.

toString(): string

Formats this handle for logging.

Returns The mine's network ID, owner and radius.

getOwner(): Player | null

The player who laid it.

Returns The owner, or null once the mine or its owner is gone.

static all(): Mine[]

Every armed mine.

Returns One handle per mine.

RadioStation

classextends Entity

A radio station every player's game carries. It joins each Pip-Boy's station list once heard and plays through world radios tuned to it, everywhere in the world. The server says what is on air and since when, so every player hears the same moment of the same track. A station outlives the resource that created it until destroyed.

Constructor
new RadioStation(id: number)

Wraps the station with this ID; it creates nothing.

id
Network entity identifier.
Properties
name: stringread-only

What the Pip-Boy lists it as; empty once it is gone.

frequency: numberread-only

The frequency it transmits on; 0 once it is gone.

sound: numberread-only

The BGSSoundDescriptorForm form ID on air; 0 while it is silent.

duration: numberread-only

How long the track on air runs, in milliseconds, as given to `play`; 0 when not given.

elapsed: numberread-only

How long the track on air has run, in milliseconds; 0 while it is silent.

Methods
stop(): boolean

Takes the track off air: every player's radio falls silent on this station.

Returns False once the station is gone.

destroy(): boolean

Takes the station off every player's radio.

Returns False once the station is gone.

toString(): string

Formats this handle for logging.

Returns The station's network ID, name and frequency.

play(sound: number | string, durationMs?: number): boolean

Puts a track on air from now, replacing what played. Only a player's data files can tell whether the form is a sound descriptor, so a wrong one stays silent. No event marks the end of a track: the script schedules the next one itself, from the duration it knows.

sound
A BGSSoundDescriptorForm form ID, as a number or hex string.
durationMs
How long it runs. With it, a player tuning in until then still hears it; without it, a player's radio drops it once it has played out.

Returns False once the station is gone.

static create(name: string, frequency: number): RadioStation | null

Creates a silent station on every player's radio.

name
What the Pip-Boy lists it as, up to 64 characters.
frequency
What it transmits on, 80 to 110, the Pip-Boy's dial; no other station may hold it. A game station on the same frequency plays over it unless the game's stations are off.

Returns The station, or null when the name or frequency was refused.

static setVanillaStationsEnabled(enabled: boolean)

Puts the game's own stations (Diamond City Radio, Classical Radio, and the quest signals and distress beacons too) on or off every player's radio. Each player's game runs them alone, so no two players hear the same thing on them. Off, they leave the Pip-Boy's list and every world radio, and the scenes behind them play out in person instead. A player joining later follows the setting.

enabled
False takes them off; true puts them back.
static areVanillaStationsEnabled(): boolean

Whether the game's own stations are on the radio.

Returns True unless a script turned them off.

static all(): RadioStation[]

Every station.

Returns One handle per station.

Npc

classextends Entity

A non-player actor the server took over from the data files: the generic placed ones, not the unique, essential or quest actors, which stay each client's own. A client near it runs it with the game's own AI and reports its health; nobody near, the server walks it. It lives for the whole session and comes back on its own a while after it dies. Move it with `teleport`, not by setting `position`.

Constructor
new Npc(id: number)

Wraps an existing NPC with this ID; it spawns nothing.

id
Network entity identifier.
Properties
ref: numberread-only

The form ID of the placed reference (ACHR) it stands for.

form: numberread-only

The TESNPC every client builds it from; the server rolled any leveled list.

health: numberread-only

Current health, as its simulator last measured it. 0 until a client has run it: the server cannot work it out from the records.

maxHealth: numberread-only

Health at full; 0 until a client has run it.

isDead: booleanread-only

Whether it is dead.

heading: numberread-only

Facing, in radians around Z.

Methods
kill(): boolean

Kills it through the path a hit takes; `npcDeath` follows with a null killer. One no client has run yet dies when the next one takes it on.

Returns True when sent; false when it is already dead.

respawn(): boolean

Puts it back at its placement, whole, dead or alive; `npcRespawn` follows.

Returns True when done.

toString(): string

Formats this handle for logging.

Returns The NPC's network ID, reference and form.

getSpace(): PlayerSpace | null

Where the NPC is.

Returns The worldspace or interior cell.

getSimulator(): Player | null

The player whose game runs the NPC.

Returns Null while nobody near does and the server walks it.

getLeader(): Player | null

The player the NPC follows as a companion.

Returns Null when it follows nobody.

setLeader(player: Player | null): boolean

Makes the NPC a player's companion, as the game's own Followers quest makes one: the leader's game runs it with the follow packages, command mode and trading of a vanilla companion, and every other player sees it follow. It is taken along when its leader goes to another space or far off, and let go when the leader leaves; `npcLeaderChange` follows.

player
Who it follows; null lets it go.

Returns True when done; false for a dead NPC or a player who is gone. Throws for anything but a Player or null.

damage(amount: number): boolean

Hits the NPC from nobody, as a shot would; `npcHit` is not raised.

amount
Health to take, above 0.

Returns True when sent; false when it is dead.

teleport(position: Vector3, heading?: number): boolean

Moves the NPC within its space. Left alone, it wanders back toward its placement over time.

position
Where to, in the NPC's own space.
heading
Facing in radians; the current one when left out.

Returns True when done. Throws for a position that is not a finite Vector3.

static all(): Npc[]

Every NPC the server took over.

Returns One handle per NPC; empty when the server could not read the game's data files.

static getById(id: number): Npc | null

Looks an NPC up by network ID.

id
Network entity identifier.

Returns The handle, or null when no NPC has that ID.

static getByRef(ref: number | string): Npc | null

Looks an NPC up by the placed reference it stands for.

ref
The placed reference's form ID.

Returns The handle, or null when the server did not take that reference over.

WorkshopItem

classextends Entity

An object built in a settlement, by a player or a script, linked to a workbench the data files place. It lasts the whole session, whoever built it, until a player scraps or stores it or a script destroys it. Setting `position` or `angle` moves it for everyone.

Constructor
new WorkshopItem(id: number)

Wraps an existing built object with this ID; it builds nothing. See `WorkshopItem.place`.

id
Network entity identifier.
Properties
form: numberread-only

The base object's form ID; 0 once it is gone.

workbench: numberread-only

The workbench reference it belongs to; 0 once it is gone.

angle: Vector3

Its rotation, radians, as the game stores it. Assigning turns it for everyone.

Methods
destroy(): boolean

Takes the object out of the settlement for everyone; nobody gets its components back.

Returns True when it was there to take.

toString(): string

Formats this handle for logging.

Returns The object's network ID, form and workbench.

getSpace(): PlayerSpace | null

Where the object stands.

Returns The worldspace or interior cell, or null once it is gone.

static place(form: number | string, workbench: number | string, position: Vector3, space: { worldSpace?: number | string; interiorCell?: number | string }, angle?: Vector3): WorkshopItem | null

Builds an object for everyone, as if a player had at that workbench. Nothing is checked: not the recipe, its cost nor the buildable area.

form
The base object to build.
workbench
The workbench reference it belongs to, placed by the data files.
position
Where it stands.
space
The worldspace, or the interior cell: exactly one of the two.
angle
Its rotation, radians.

Returns The object, or null when it could not be created.

static all(workbench?: number | string): WorkshopItem[]

Every object built this session.

workbench
Only the objects of this workbench.

Returns One handle per object.

Timeout

type

Node.js timer handle returned by setTimeout and setInterval.

Methods
ref(): Timeout

Keeps the event loop alive while this timer is pending.

Returns This timer.

unref(): Timeout

Lets the event loop exit while this timer is still pending.

Returns This timer.

hasRef(): boolean

Whether this timer keeps the event loop alive.

refresh(): Timeout

Restarts this timer's countdown from now, with its original delay.

Returns This timer.

Timers

Free functions, the same shape as the browser and Node ones.

Timers

global
Methods
setTimeout(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout

Calls a function once after a delay.

handler
Function to call.
milliseconds
Delay before the call.
args
Arguments passed to the handler.

Returns Handle to pass to the matching clear function.

setInterval(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout

Calls a function repeatedly, waiting the delay between calls.

handler
Function to call.
milliseconds
Delay before the call.
args
Arguments passed to the handler.

Returns Handle to pass to the matching clear function.

clearTimeout(handle?: Timeout)

Cancels a pending setTimeout.

handle
Handle returned when the timer was scheduled; anything else is ignored.
clearInterval(handle?: Timeout)

Cancels a setInterval.

handle
Handle returned when the timer was scheduled; anything else is ignored.
queueMicrotask(callback: () => void)

Queues a function on the microtask queue.

callback
Function to run once the current task completes.
The illuminated entrance to Vault 111

Your next chapter starts here

The vault door
is open

Find the latest builds, meet your future neighbours, and help shape what comes next. We’re building this Commonwealth together.

Join the Discord Bring your Pip-Boy, we’ll bring the company