Sanctuary
constSanctuary:object
Defined in: server/api.d.ts:5596
Room of Requirement instances. A room is a layout under an id the script chooses, and nobody owns one: a script says where each player’s castle door leads (their destination), takes players into any room with enter, and grants edit rights room by room. Players in the same room see each other and its editors’ changes live. The server holds rooms only while it runs: save Sanctuary.get(id) from sanctuaryChanged, and Sanctuary.load it back.
Type Declaration
Section titled “Type Declaration”addBeast()
Section titled “addBeast()”addBeast(
id,vivarium,beast):Beast|null
Puts a beast into a room’s vivarium, as if an editor released it there. Null when the room is not loaded, or the vivarium already holds 12 beasts or 4 other species. Throws on an unknown species, a color it does not have, a bad gender or a name over 64 bytes.
Parameters
Section titled “Parameters”string
vivarium
Section titled “vivarium”"Forest" | "Swamp" | "Coastal" | "Grassland"
Omit<SanctuaryBeast, "id" | "vivarium">
Its vivarium is the argument’s; its id is the room’s to give.
Returns
Section titled “Returns”Beast | null
beasts()
Section titled “beasts()”beasts(
id,vivarium?):Beast[]
The beasts living in a loaded room’s vivariums. Players in the room see them, and their game counts them as its own vivarium beasts. Destroying one, or a catch, takes it out of the room.
Parameters
Section titled “Parameters”string
vivarium?
Section titled “vivarium?”"Forest" | "Swamp" | "Coastal" | "Grassland"
Only this vivarium’s.
Returns
Section titled “Returns”Beast[]
destination()
Section titled “destination()”destination(
player):string|null
The room the castle door or fast travel takes the player into.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”string | null
door()
Section titled “door()”door():
"open"|"closed"|"proximity"
The castle door’s mode.
Returns
Section titled “Returns”"open" | "closed" | "proximity"
doorAccess()
Section titled “doorAccess()”doorAccess(
player):boolean
Whether the castle door opens for the player: allowed, with a loaded destination.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”boolean
editors()
Section titled “editors()”editors(
id):Player[]
Players allowed to edit the room. Not part of the layout.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Player[]
enter()
Section titled “enter()”enter(
player,id):boolean
Takes the player into a room now, behind the game’s own loading screen: from Overland, or from inside another room, swapped in place. Their destination stays as it was. False when no room is loaded under that id.
Parameters
Section titled “Parameters”player
Section titled “player”string
Returns
Section titled “Returns”boolean
get(
id):SanctuaryLayout|null
A room’s saved form, ready to store; null when no room is loaded under that id.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”SanctuaryLayout | null
ids():
string[]
Every loaded room’s id.
Returns
Section titled “Returns”string[]
inside()
Section titled “inside()”inside(
player):string|null
The room the player is standing in.
Parameters
Section titled “Parameters”player
Section titled “player”Returns
Section titled “Returns”string | null
load()
Section titled “load()”load(
id,layout):boolean
Creates or replaces a room. Players heading for it are restaged; players inside see the difference applied, and a change to its locks or lighting reloads them into it behind the loading screen.
Parameters
Section titled “Parameters”string
layout
Section titled “layout”Returns
Section titled “Returns”boolean
nativeEntry()
Section titled “nativeEntry()”nativeEntry():
boolean
Whether the castle door lets players in itself; false by default.
Returns
Section titled “Returns”boolean
nativeStations()
Section titled “nativeStations()”nativeStations(
types?):boolean
Whether every one of the kinds offers the game’s own F prompt and menu; true by default.
Parameters
Section titled “Parameters”types?
Section titled “types?”("planter" | "potionStation" | "loom")[]
Only these kinds; every kind when left out.
Returns
Section titled “Returns”boolean
occupants()
Section titled “occupants()”occupants(
id):Player[]
Players standing in a room.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Player[]
revision()
Section titled “revision()”revision(
id):number|null
Bumped on every load and accepted edit; the number sanctuaryChanged carries.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number | null
setDestination()
Section titled “setDestination()”setDestination(
player,id):void
The room the castle door or fast travel takes the player into; null leads nowhere. A room not loaded yet is staged once it loads, and the door stays shut until then, so set it before the room is read back from storage.
Parameters
Section titled “Parameters”player
Section titled “player”string | null
Returns
Section titled “Returns”void
setDoor()
Section titled “setDoor()”setDoor(
mode):void
The castle door for everyone. proximity (the default): it reveals while any player stands at it, and every player watching sees the reveal. open: always revealed. closed: never revealed, so nobody walks in.
Parameters
Section titled “Parameters”"open" | "closed" | "proximity"
Returns
Section titled “Returns”void
setDoorAccess()
Section titled “setDoorAccess()”setDoorAccess(
player,allowed):void
Whether the castle door may open for the player; true unless a script says otherwise. It only ever opens toward a loaded destination. A player without access still reveals the door and sees it, but it stays shut for them. A script’s own door should ask doorAccess too.
Parameters
Section titled “Parameters”player
Section titled “player”allowed
Section titled “allowed”boolean
Returns
Section titled “Returns”void
setEditor()
Section titled “setEditor()”setEditor(
id,player,allowed):void
Whether the player may edit the room; their changes reach everyone inside. Held for the player’s connection, and kept across the room’s loads and unloads.
Parameters
Section titled “Parameters”string
player
Section titled “player”allowed
Section titled “allowed”boolean
Returns
Section titled “Returns”void
setNativeEntry()
Section titled “setNativeEntry()”setNativeEntry(
enabled):void
Whether the castle door lets players in itself; false by default. Off, it still reveals, but no player can walk in or gets the game’s prompt: a script shows its own prompt (the client’s Sanctuary.door) and calls enter. On, the game’s walk-in works for players with door access.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
setNativeStations()
Section titled “setNativeStations()”setNativeStations(
enabled,types?):void
Whether the room’s stations offer the game’s own F prompt and menu; on by default. Off, no player gets them in any room, so a script can run its own herbology, brewing or gear upgrades there: it shows its own prompt (the client’s Sanctuary.objects gives each one’s type and position). The game’s interaction is gone too, so the client’s objectInteracted does not fire on them. Plots and benches from Herbology.place and Brewing.place keep theirs.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
types?
Section titled “types?”("planter" | "potionStation" | "loom")[]
Only these kinds; every kind when left out.
Returns
Section titled “Returns”void
unload()
Section titled “unload()”unload(
id):boolean
Drops a room that is nobody’s destination and that nobody is in or entering.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean