Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Data shapeClient APIGenerated

EventMap

Defined in: client/api.d.ts:7

Native events dispatched through Events.on. Each property is the exact callback argument tuple for that event.

actionHintsChanged: []

Defined in: client/api.d.ts:144

Dispatched when what the HUD’s hints say changes: one appears or goes, changes its text, is greyed out, or a hold ring moves. ActionHint.shown() reads the new set. Handler promises are not awaited.


bookClosed: [number, "script" | "player" | "sessionOver" | "failed"]

Defined in: client/api.d.ts:124

Dispatched when a book leaves the player’s hands, on this machine only. reason is player for the player’s own exit (or the game ending the reading itself), script for Book.close, failed for a book that never reached the hands, and sessionOver for the session ending. Handler promises are not awaited, and a handler may open the next book straight away.


bookOpened: [number]

Defined in: client/api.d.ts:119

Dispatched when a book Book.open asked for is in the player’s hands and showing its first page, on this machine only.


browserConsoleMessage: [BrowserConsoleMessageEvent]

Defined in: client/api.d.ts:214

Dispatched for console output of an owned view; the framework logs these regardless.


browserCreated: [BrowserCreatedEvent]

Defined in: client/api.d.ts:164

Dispatched once per view, before any navigation, to the resource that created it.


browserCursorChange: [BrowserCursorChangeEvent]

Defined in: client/api.d.ts:194

Dispatched when an owned view’s requested cursor shape changes.


browserDocumentReady: [BrowserDocumentReadyEvent]

Defined in: client/api.d.ts:174

Dispatched when an owned view’s main document is ready; the earliest point at which the page can receive Web.emit.


browserInputFocusChange: [BrowserInputFocusChangeEvent]

Defined in: client/api.d.ts:204

Dispatched when focus enters or leaves an editable element of an owned view; use it to stop routing keys to the game.


browserLoadingFailed: [BrowserLoadingFailedEvent]

Defined in: client/api.d.ts:179

Dispatched when a frame of an owned view fails to load.


browserLoadingStart: [BrowserLoadingStartEvent]

Defined in: client/api.d.ts:169

Dispatched when any frame of an owned view begins loading.


browserNavigate: [BrowserNavigateEvent]

Defined in: client/api.d.ts:184

Dispatched for every navigation an owned view is asked to perform, refused or not.


browserOriginChange: [BrowserOriginChangeEvent]

Defined in: client/api.d.ts:219

Dispatched on view creation and whenever Web.loadURL re-locks an owned view to a different origin.


browserPopup: [BrowserPopupEvent]

Defined in: client/api.d.ts:189

Dispatched when an owned view blocks a popup; windowless views cannot host one, so handle the URL yourself.


browserResourceBlocked: [BrowserResourceBlockedEvent]

Defined in: client/api.d.ts:209

Dispatched when an owned view rejects a navigation or a page event from outside its locked origin.


browserTooltip: [BrowserTooltipEvent]

Defined in: client/api.d.ts:199

Dispatched when an owned view requests a tooltip; windowless rendering draws none, so the script must.


characterCreatorClosed: [Appearance | null, "replaced" | "unavailable" | "interrupted" | "accepted" | "cancelled" | "closed"]

Defined in: client/api.d.ts:139

Dispatched once for every creator, on this machine only, whatever ended it. appearance is the look the player accepted, and null for every other ending. reason is accepted, cancelled for the player backing out, closed for CharacterCreator.close, replaced for another CharacterCreator.open, unavailable when the stage could not be put up, and interrupted when the session or the body went away under it. Nothing is put on the body: send the look wherever it should go – Events.emitServer, then player.setAppearance on the server – or open the next creator straight from the handler.


doorInteract: [DoorUse, "open" | "close" | "unlock" | "lockpick", boolean]

Defined in: client/api.d.ts:62

Dispatched on this machine when the local player uses a door, before anything happens: the door has not moved, the body has not started, and the server has not been told. action is open, close, unlock or lockpick, as server-side doorInteract has it; a key turned in the same use as the push arrives as unlock and then open, and refusing the unlock refuses the use without asking about the open. keySide says whether the player stands on the side with the keyhole.

Return false to refuse it: the use does nothing, with no round trip and nothing to put back. Every handler runs whatever an earlier one returned, and an async handler cannot refuse. A door the server made unusable (door.usable there) offers no prompt and never gets here.

It is this machine’s own rule. The server’s doorInteract still decides what it is told, so a refusal that has to hold against a modified client belongs there as well.


entityStateChange: [Entity, string, any, any]

Defined in: client/api.d.ts:159

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.


followStarted: [FollowTarget]

Defined in: client/api.d.ts:129

The local native follow action has entered. A successful start request may still fail before this event.


followStopped: [FollowTarget, "input" | "script" | "failed" | "targetLost" | "mountChanged" | "teleported" | "unavailable" | "interrupted" | "resourceStopped" | "sessionEnded" | "worldChanged"]

Defined in: client/api.d.ts:134

A queued or active scripted follow ended on this client.


locationDiscovered: [LocationId]

Defined in: client/api.d.ts:82

Dispatched when a location – a town, a district – becomes discovered at this machine through the game’s own discovery, which only happens while the server’s reveal_map is off. WorldMap.discover does not raise it. Handler promises are not awaited.


mapClosed: []

Defined in: client/api.d.ts:97

Dispatched when the map screen goes away.


mapOpened: []

Defined in: client/api.d.ts:92

Dispatched when the map screen comes up at this machine.


mapWaypointCleared: [Vector3, number]

Defined in: client/api.d.ts:107

Dispatched when the player takes their marker off the map, including through WorldMap.clearWaypoint. It carries where the marker was, since afterwards nothing says.


mapWaypointSet: [Vector3, number, boolean]

Defined in: client/api.d.ts:102

Dispatched when the player drops their own marker on the map, or moves the one already down – moved separates the two, because the game uses one action for both. The position is world-space metres. Maps reuse one coordinate range, which is why mapId travels with it.


monologueSuppressed: [string, string]

Defined in: client/api.d.ts:43

Dispatched when a monologue line of the local character – a photo-mode comment, the sharpening remark – was kept silent and unsubtitled. text is localized; textKey is its localization key. Not raised while Hud.setMonologueEnabled(true) has released it. Handler promises are not awaited.


noclipChanged: [boolean, "script" | "sessionOver" | "mapEditor" | "viewLost"]

Defined in: client/api.d.ts:114

Dispatched when the flight starts and when it ends, on this machine only. Handler promises are not awaited.

reason is script on the way in. On the way out it is script for a resource ending it, mapEditor for the map editor taking the one camera, viewLost for the level going away underneath the camera’s anchor, and sessionOver for the session ending.


playerReady: [Player]

Defined in: client/api.d.ts:13

Dispatched once per session, when the local player can play: the session is established and the game has taken its own loading screen down. The game raises that moment itself – it is its own gameplay-start signal, not a guess from timing.

Resources are running long before this, so it is not the moment a resource may start listening; it is the moment the player is looking at the world. Put what the player should see on arrival here – a welcome, a first page – rather than in resourceStart, which runs behind the loading screen. The server raises its own playerReady for this player right after.


poiDiscovered: [LocationId]

Defined in: client/api.d.ts:77

Dispatched when a point of interest becomes discovered at this machine: silently while the server’s reveal_map is on, as the game’s own discovery when it is off, and for each one WorldMap.discover marks. Handler promises are not awaited. A position merely made known emits nothing.


progressionLevelUp: [string, number, number]

Defined in: client/api.d.ts:23

Dispatched when a track of the local player’s reaches a new level. perkPoints is what that track’s tree now has unspent.


progressionPerkAdded: [string]

Defined in: client/api.d.ts:28

Dispatched when the local player gained a perk: learnt on the perk screen and granted by the server, given by a server resource, or granted by the game on its own.


progressionPerkRefused: [string, "script" | "points" | "level" | "parent" | "exclusive" | "blocked" | "owned" | "hidden"]

Defined in: client/api.d.ts:38

Dispatched when the server turned down a perk the local player confirmed on the perk screen. The game’s own screen says nothing when that happens, so this is where a resource tells the player why.


progressionPerkRemoved: [string]

Defined in: client/api.d.ts:33

Dispatched when the local player lost a perk.


progressionXpGained: [string, number]

Defined in: client/api.d.ts:18

Dispatched when the local player’s XP on a track went up: after the server granted a gain and the game applied it, with its own multipliers. xp is what landed, in the game’s own units.


questTrackingChanged: [string, boolean]

Defined in: client/api.d.ts:53

Dispatched when this player starts or stops following a server quest in the game’s journal, whichever way it happened: the track button, the game auto-tracking a quest that turns active, or the untrack that follows finishing or failing one. Local to this machine and raised before the server is told; the server raises its own questTrackingChanged when the report arrives. Repeats are filtered, so it only fires on an actual change. Handler promises are not awaited.


resourceStart: [string]

Defined in: client/api.d.ts:149

Dispatched after a resource entry point has run and immediately before the resource becomes running.


resourceStop: [string]

Defined in: client/api.d.ts:154

Dispatched while a resource is stopping, before its stop callback, timers, exports and event handlers are cleaned up.


storyCutsceneSuppressed: [string]

Defined in: client/api.d.ts:48

Dispatched when a quest asked to play a story cutscene and multiplayer kept it from playing, so the player stays in control and the world clock runs on. cutscene is its name in the game’s cutscene table. Not raised while Hud.setStoryCutscenesEnabled(true) has released them. Handler promises are not awaited.


vendorClosed: [number, "player" | "server" | "replaced" | "levelChange" | "sessionOver"]

Defined in: client/api.d.ts:72

Dispatched when a trade screen that vendorOpened announced goes away: the player closed it, the server closed it, the server opened another vendor over it, the level changed under it, or the connection ended. A screen that never came up raises neither event. The server raises its own vendorClosed for the session.


vendorOpened: [number, number | null]

Defined in: client/api.d.ts:67

Dispatched when the game’s trade screen actually comes up on this machine for a server vendor – not when the server asked for it, which can take a few frames or fail. npc is the network ID of the NPC keeping the shop, or null when nobody does. Every vendorOpened is followed by exactly one vendorClosed.


weaponHit: [WorldRayHit]

Defined in: client/api.d.ts:87

Dispatched on this machine when the local player’s swing meets something solid that is not a body: a tree, a wall, a rock, a prop, the ground. Once per thing per attack, at the first contact, as the game itself counts it; a blade that rests against a wall is not reported again. hit is named as a trace names it, with distance measured from the player’s feet. Fists and kicks are not reported, and neither is a blow on a player, an NPC or an animal, which playerHit and the damage events cover. The server hears of it as playerWeaponHit.