Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectServer APIGenerated

Crafting

const Crafting: object

Defined in: server/api.d.ts:3886

Crafting catalogs, station occupancy, alchemy and smithing sessions, and alchemy recipe knowledge. Held in memory for each connection; nothing is saved.

cancel(player): boolean

Ends the player’s session as leaving the station would, and their game closes it. Alchemy: wholly unmilled groups go back to the inventory, the rest is spent. Smithing: the workpiece fails, spending its failure share. craftingEnded follows next tick. False when there was nothing to end.

Player

boolean

isAvailable(kind?): boolean

True: alchemy and smithing are both ruled by the server. Omitted kind checks alchemy.

"alchemy" | "smithing"

boolean

knowledge(player): Record<string, number>

The player’s recipe knowledge: recipe id to a mask of its 29 authored steps, 536870911 when the whole recipe is known. A recipe not listed is unknown. Starts empty every session; save it from craftingCompleted or here and restore it with setKnowledge.

Player

Record<string, number>

occupancy(stationId, virtualWorld?): CraftStationOccupancy | null

Who holds a station. World defaults to 0. Null for an unknown station.

string

number

CraftStationOccupancy | null

recipes(player, kind?): readonly CraftRecipeInfo[]

Every recipe enabled by server DLC policy: the game’s, then streamed mods’ and scripts’ in the order they were added. A mod’s table patch row with a game recipe’s id replaces it in place. The player must be connected but does not change the list. Catalog presence does not establish knowledge or skill.

Player

"alchemy" | "smithing"

readonly CraftRecipeInfo[]

registerRecipe(definition): void

Adds an alchemy or smithing recipe for the rest of the server’s life. The server brews and forges it by the same rules as the game’s recipes, Crafting.recipes lists it, and every client, including one that joins later, adds it to the game’s own recipe book and smithy. Registering the same definition again does nothing. Throws for a malformed definition, an item the catalog does not know, an id the game or another resource uses, or a different definition under an id already registered.

CraftRecipeDefinition

void

session(player): CraftSessionInfo | null

The player’s alchemy session or the table they kept between batches, else their smithing workpiece, else null.

Player

CraftSessionInfo | null

setKnowledge(player, recipeId, mask): boolean

Sets which steps of one recipe the player knows, and sends it to their game’s recipe book. 0 forgets the recipe. False for an unknown recipe, a mask above 536870911, or a player who is not connected.

Player

string | number

number

boolean

stations(kind?, virtualWorld?): readonly CraftStationInfo[]

The stations players in a virtual world can craft at: the level’s own, minus any a level edit took out of that world, and every station SmartObject.spawn or a World Builder export placed there or in the global world. Does not load deferred layers or bypass quests.

"alchemy" | "smithing"

number

Optional virtual world whose stations to list; the global one when omitted.

readonly CraftStationInfo[]