World
constWorld:object
Defined in: client/api.d.ts:6050
Current level and world-streaming state.
Type Declaration
Section titled “Type Declaration”
readonlystate:StateBag|null
Global replicated key/value state written by the server and shared by every resource. Read-only here. Null until the world entity streams in. See StateBag.
stateId
Section titled “stateId”
readonlystateId:number
Network id of the entity carrying World.state, for filtering the global entityStateChange bus. 0 before it streams in.
ambientPopulation()
Section titled “ambientPopulation()”ambientPopulation():
boolean
Whether ambient population is currently restored.
Returns
Section titled “Returns”boolean
clearLocalOverride()
Section titled “clearLocalOverride()”clearLocalOverride():
void
Hands this client’s weather, clock and season back to the server.
Returns
Section titled “Returns”void
collectablePolicy()
Section titled “collectablePolicy()”collectablePolicy():
object
The per-family suppression policy: {fieldGuidePages, flyingBooks, spawnedPages}.
Returns
Section titled “Returns”object
commonRoomEntrances()
Section titled “commonRoomEntrances()”commonRoomEntrances():
object
Each house’s common-room entrance on this client: the server’s World.setCommonRoomEntrance for it, whether it is loaded here, whether it stands open or opening (null when not loaded), and whether the local player stands in its trigger, the spot where it decides whom to let in (e.g. to ask for a password there).
Returns
Section titled “Returns”object
Gryffindor
Section titled “Gryffindor”Gryffindor:
CommonRoomEntrance
Hufflepuff
Section titled “Hufflepuff”Hufflepuff:
CommonRoomEntrance
Ravenclaw
Section titled “Ravenclaw”Ravenclaw:
CommonRoomEntrance
Slytherin
Section titled “Slytherin”Slytherin:
CommonRoomEntrance
currentLevelName()
Section titled “currentLevelName()”currentLevelName():
string
Returns the current level name.
Returns
Section titled “Returns”string
isReady()
Section titled “isReady()”isReady():
boolean
Returns whether the playable world is ready.
Returns
Section titled “Returns”boolean
leadVelocity()
Section titled “leadVelocity()”leadVelocity(
sx,sy,sz,tx,ty,tz,tvx,tvy,tvz,speed,gravity?):object|null
The engine’s ballistic lead solver: the velocity to launch from the source at to hit a target moving at a constant velocity. Returns {x,y,z,time}; time 0 means no solution. Magnitude is sqrt(speed^2 + |targetVel|^2) — a shipped bug, so pass sqrt(S^2 - |tv|^2) for exactly S.
Parameters
Section titled “Parameters”number
number
number
number
number
number
number
number
number
number
gravity?
Section titled “gravity?”number
Returns
Section titled “Returns”object | null
lineTrace()
Section titled “lineTrace()”lineTrace(
start,end,options?):TraceHit|null
Traces a line through this client’s collision and returns the first blocking hit, or null on a miss. Only loaded levels have collision, so a trace into an area this client has not streamed in finds nothing. Throws a TypeError on a bad argument.
Parameters
Section titled “Parameters”Where the trace starts, in world centimetres.
Where it ends.
options?
Section titled “options?”Channel or object types, and what to pass through.
Returns
Section titled “Returns”TraceHit | null
localOverride()
Section titled “localOverride()”localOverride(): {
hour?:number;minute?:number;owner:string;season?:number;weather?:string; } |null
The override setLocalOverride set, with the resource that set it; null when the server’s environment shows.
Returns
Section titled “Returns”{ hour?: number; minute?: number; owner: string; season?: number; weather?: string; } | null
populationDensity()
Section titled “populationDensity()”populationDensity():
number
The crowd density setPopulationDensity applied, 1 by default.
Returns
Section titled “Returns”number
populationExclusions()
Section titled “populationExclusions()”populationExclusions():
PopulationExclusions
The scheduled NPCs currently kept out of the world.
Returns
Section titled “Returns”populationExemptions()
Section titled “populationExemptions()”populationExemptions():
string[]
The NPC names currently exempt from population suppression.
Returns
Section titled “Returns”string[]
scheduledEntities()
Section titled “scheduledEntities()”scheduledEntities():
ScheduledEntityInfo[]
Every NPC the game’s scheduler holds on this client: its name (what setPopulationExemptions and setPopulationExclusions take), its game subtype, whether it is spawned or excluded, and where its schedule has it. Named NPCs are listed wherever they are; crowd NPCs only while the crowd has them out, and several may share a name.
Returns
Section titled “Returns”setAmbientPopulation()
Section titled “setAmbientPopulation()”setAmbientPopulation(
enabled):boolean
Restores the game’s ambient population (students, seat fillers, Tier-4 crowd extras). The mod suppresses it by default, so crowds need this on first. Turning it off returns every Tier-4 extra already out, except an exempt NPC’s own.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”boolean
setBoundaryPolicy()
Section titled “setBoundaryPolicy()”setBoundaryPolicy(
remove):number
Sets boundary-volume enforcement.
Parameters
Section titled “Parameters”remove
Section titled “remove”boolean
Returns
Section titled “Returns”number
setCollectablePolicy()
Section titled “setCollectablePolicy()”setCollectablePolicy(
suppress,families?):number
Disables field-guide collectables without writing any save state; returns actors written. Turning it off re-arms the hotspots, but destroyed books and pages only return when their cell re-streams. Chests, ancient magic, astronomy, Merlin trials and balloons are separate systems and are not covered.
Parameters
Section titled “Parameters”suppress
Section titled “suppress”boolean
families?
Section titled “families?”object
Which families to act on: fieldGuidePages, flyingBooks, spawnedPages. Omit for all; with it, only the keys set true are touched.
Returns
Section titled “Returns”number
setLocalOverride()
Section titled “setLocalOverride()”setLocalOverride(
override):void
Shows this client its own weather, time of day and season in place of the server’s, e.g. while a character creator is open. Fields left out follow the server. Replaces any earlier override, from any resource, and ends when clearLocalOverride is called or the resource that set it stops.
Parameters
Section titled “Parameters”override
Section titled “override”weather: a template name, as World.setWeather takes on the server. hour 0-23 and minute 0-59 stop this client’s clock there. season 0-3 (spring, summer, autumn, winter). An empty object clears.
number
minute?
Section titled “minute?”number
season?
Section titled “season?”number
weather?
Section titled “weather?”string
Returns
Section titled “Returns”void
setPopulationDensity()
Section titled “setPopulationDensity()”setPopulationDensity(
density):number
Thins the ambient crowd on this client: every crowd lane (wandering and seated students and townsfolk, spline walkers, world-event extras) may have only this share of the player’s own Population quality out, and this share of the Tier-4 background extras gets through. Named NPCs are not affected. A crowd already out thins as it turns over, not at once. Returns the value applied. 1 by default and again when the session ends; call it from playerRegionChanged for a density per area, e.g. 0 for HM_ and Hogsmeade regions, 0.3 for HOG_ ones and Hogwarts.
Parameters
Section titled “Parameters”density
Section titled “density”number
0 (no crowd) to 1 (the game’s own); outside that range it is clamped.
Returns
Section titled “Returns”number
setPopulationExclusions()
Section titled “setPopulationExclusions()”setPopulationExclusions(
exclusions):PopulationExclusions
Keeps these scheduled NPCs out of the world, with ambient population on or off: one already spawned goes away within a second, and one listed again later comes back on its own schedule. Types also refuse the matching Tier-4 crowd extras (T4Student, T4Townsperson, T4DarkWizard, T4Goblin) from then on. Replaces both lists and returns them deduplicated; an unknown type throws. Empty by default and cleared when the session ends.
Parameters
Section titled “Parameters”exclusions
Section titled “exclusions”names: scheduled-entity names, e.g. “GerboldOllivander”. types: game subtypes, e.g. “T3Student”, or the groups “vendors”, “students” and “townsfolk”.
Returns
Section titled “Returns”setPopulationExemptions()
Section titled “setPopulationExemptions()”setPopulationExemptions(
ids):string[]
Keeps these named NPCs scheduled while ambient population is off, so a location-bound character such as the Fat Lady’s portrait is not left empty. Replaces the whole list and returns it deduplicated. Empty by default and cleared when the session ends. Removing an id stops scheduling that NPC but does not despawn one already in the world.
Parameters
Section titled “Parameters”string[]
Scheduled-entity names, e.g. “FatLady”.
Returns
Section titled “Returns”string[]
worldObjectState()
Section titled “worldObjectState()”worldObjectState(
networkId):WorldObjectClientState|null
Returns this client’s replicated world-object and spawned-actor state, or null when the replica is absent.
Parameters
Section titled “Parameters”networkId
Section titled “networkId”number
Server world-object network id.
Returns
Section titled “Returns”WorldObjectClientState | null