API overview

All SDK features are in one global object, kcds, which every script has without an import. It is divided into six domains:

DomainContents
kcds.coreevents, chat, sharing between resources, runtime information
kcds.mathvectors, quaternions and colours
kcds.playersplayers, their stats, inventories and progression
kcds.charactersNPCs, animals, dialogue, quests and shops
kcds.worldplaces, objects and world systems
kcds.uiscreens, 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

TypePurpose
Eventsgame events and your own, in both directions
Chatchat messages and the default relay
Exports, Imports, Messagessharing between resources on one side
SharedStatevalues on entities and the server, sent to players
Timers, Runtimescheduling and runtime details
Localestext in each player's language
processthe part of Node's process server scripts can read

Players and characters

TypePurpose
Playera connected player, with body, stats, inventory and animations
Entitywhat players, NPCs and horses have in common
Npc, Horse, HorseLooks, Dog, PatrolRouteNPCs and animals
Appearances, PlayerStat, DerivedPlayerStatlooks and stat names
Animationsthe game's animations and their held tools

World

TypePurpose
Worldtime of day and weather
Area, Marker, Blipregions, ground markers and map icons
Prop, PropGhost, PropPlacer, GroundItem, Vfxobjects and effects
Door, Gate, Stash, Cartthings players use
LevelEdit, WorldResource, Gizmochanging the level
SiegeEngine, SiegeLadder, StonePilesiege

Gameplay

TypePurpose
Inventory, Itemswhat players carry
Buffs, Needs, Progressioneffects, needs and skills
Quest, Dialogue, Vendorquests, conversations and shops
Crafting, Recipe, CookPot, Gathering, Dice, Pickpocketingactivities
Tradeone 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

TypePurpose
Hud, ActionHint, Book, Compass, WorldMap, Travelon-screen information, the map and travel
Key, Controlsinput
WebHTML pages over the game
NativeUI, NativeScreen, NativeElement, NativeClipthe game's own interface
NoClip, CharacterCreator, LocalNpc, LocalPlayer, Gizmosthe free camera, character creator and local objects
Renderpictures from any camera, unseen by the player
Followmakes the local player follow someone
Audio, Assetsgame sounds and files a resource ships
Nameplates, EmoteWheel, Discordnameplate display, the emote wheel, Discord status

Math

Vector2, Vector3, Vector4, Quaternion and Color. See also Math types.