API overview
All SDK features are in one global object, kcds, which every script has without an import. It is
divided into six domains:
| Domain | Contents |
|---|---|
kcds.core | events, chat, sharing between resources, runtime information |
kcds.math | vectors, quaternions and colours |
kcds.players | players, their stats, inventories and progression |
kcds.characters | NPCs, animals, dialogue, quests and shops |
kcds.world | places, objects and world systems |
kcds.ui | screens, input and the camera |
So you write kcds.world.Door for a door and kcds.core.Events.on(...) for an event listener. Text in
these docs often shortens a type to its name, such as Door, but code always needs the full path. To
shorten your code, unpack what you need at the top of a file:
const { Events, Chat } = kcds.core; const { Door } = kcds.world;
Standard JavaScript and web features such as console, setTimeout and fetch are still global.
Each type has a reference page listing its members, parameters and examples. A type may work in
serverScripts, in clientScripts or on both sides. Coming from an older version? See API
changes.
Scripting basics
| Type | Purpose |
|---|---|
| Events | game events and your own, in both directions |
| Chat | chat messages and the default relay |
| Exports, Imports, Messages | sharing between resources on one side |
| SharedState | values on entities and the server, sent to players |
| Timers, Runtime | scheduling and runtime details |
| Locales | text in each player's language |
| process | the part of Node's process server scripts can read |
Players and characters
| Type | Purpose |
|---|---|
| Player | a connected player, with body, stats, inventory and animations |
| Entity | what players, NPCs and horses have in common |
| Npc, Horse, HorseLooks, Dog, PatrolRoute | NPCs and animals |
| Appearances, PlayerStat, DerivedPlayerStat | looks and stat names |
| Animations | the game's animations and their held tools |
World
| Type | Purpose |
|---|---|
| World | time of day and weather |
| Area, Marker, Blip | regions, ground markers and map icons |
| Prop, PropGhost, PropPlacer, GroundItem, Vfx | objects and effects |
| Door, Gate, Stash, Cart | things players use |
| LevelEdit, WorldResource, Gizmo | changing the level |
| SiegeEngine, SiegeLadder, StonePile | siege |
Gameplay
| Type | Purpose |
|---|---|
| Inventory, Items | what players carry |
| Buffs, Needs, Progression | effects, needs and skills |
| Quest, Dialogue, Vendor | quests, conversations and shops |
| Crafting, Recipe, CookPot, Gathering, Dice, Pickpocketing | activities |
| Trade | one player's inventory as a shop for another |
Hosting
- Queue: the join queue on a full server
- Http: a resource's HTTP routes, next to the server's status API
Server switches
Camera for scripted shots, ThirdPerson, Freecam, Interactions, CombatMarker and RestrictedAreaMarker.
Client only
| Type | Purpose |
|---|---|
| Hud, ActionHint, Book, Compass, WorldMap, Travel | on-screen information, the map and travel |
| Key, Controls | input |
| Web | HTML pages over the game |
| NativeUI, NativeScreen, NativeElement, NativeClip | the game's own interface |
| NoClip, CharacterCreator, LocalNpc, LocalPlayer, Gizmos | the free camera, character creator and local objects |
| Render | pictures from any camera, unseen by the player |
| Follow | makes the local player follow someone |
| Audio, Assets | game sounds and files a resource ships |
| Nameplates, EmoteWheel, Discord | nameplate display, the emote wheel, Discord status |
Math
Vector2, Vector3, Vector4, Quaternion and Color. See also Math types.