Crafting
constCrafting: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.
Type Declaration
Section titled “Type Declaration”cancel()
Section titled “cancel()”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.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”boolean
isAvailable()
Section titled “isAvailable()”isAvailable(
kind?):boolean
True: alchemy and smithing are both ruled by the server. Omitted kind checks alchemy.
Parameters
Section titled “Parameters”"alchemy" | "smithing"
Returns
Section titled “Returns”boolean
knowledge()
Section titled “knowledge()”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.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”Record<string, number>
occupancy()
Section titled “occupancy()”occupancy(
stationId,virtualWorld?):CraftStationOccupancy|null
Who holds a station. World defaults to 0. Null for an unknown station.
Parameters
Section titled “Parameters”stationId
Section titled “stationId”string
virtualWorld?
Section titled “virtualWorld?”number
Returns
Section titled “Returns”CraftStationOccupancy | null
recipes()
Section titled “recipes()”recipes(
player,kind?): readonlyCraftRecipeInfo[]
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.
Parameters
Section titled “Parameters”player
Section titled “player”"alchemy" | "smithing"
Returns
Section titled “Returns”readonly CraftRecipeInfo[]
registerRecipe()
Section titled “registerRecipe()”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.
Parameters
Section titled “Parameters”definition
Section titled “definition”Returns
Section titled “Returns”void
session()
Section titled “session()”session(
player):CraftSessionInfo|null
The player’s alchemy session or the table they kept between batches, else their smithing workpiece, else null.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”CraftSessionInfo | null
setKnowledge()
Section titled “setKnowledge()”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.
Parameters
Section titled “Parameters”player
Section titled “player”recipeId
Section titled “recipeId”string | number
number
Returns
Section titled “Returns”boolean
stations()
Section titled “stations()”stations(
kind?,virtualWorld?): readonlyCraftStationInfo[]
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.
Parameters
Section titled “Parameters”"alchemy" | "smithing"
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world whose stations to list; the global one when omitted.
Returns
Section titled “Returns”readonly CraftStationInfo[]