HogwartsExpress
Defined in: server/api.d.ts:4520
The Hogwarts Express, reached as World.hogwartsExpress. The server runs it and every client draws it at the same spot; the game’s own timetable is off, so it runs only when a script moves it. Positions are t along its one track, from 0 (the whole train just on the track, south of Hogsmeade) to 1 (the far end), or the id of a stop. It runs forward only. Events: trainSpawned(t), trainStopped(t), trainEnded(reason).
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HogwartsExpress():
HogwartsExpress
Returns
Section titled “Returns”HogwartsExpress
Methods
Section titled “Methods”depart()
Section titled “depart()”depart(
options?):boolean
Defined in: server/api.d.ts:4551
Runs the train off the far end of the track at its cruise speed. It despawns there (trainEnded “end”).
Parameters
Section titled “Parameters”options?
Section titled “options?”As for moveTo; decel only slows it to a lower cruise speed.
accel?
Section titled “accel?”number
decel?
Section titled “decel?”number
speed?
Section titled “speed?”number
Returns
Section titled “Returns”boolean
False with no train, one already leaving the track, or bad options.
despawn()
Section titled “despawn()”despawn():
boolean
Defined in: server/api.d.ts:4564
Removes the train at once (trainEnded “despawned”).
Returns
Section titled “Returns”boolean
False with no train.
get():
object
Defined in: server/api.d.ts:4569
Where the train is now. t and speed (m/s) are meaningful while spawned; target is the t a moveTo or halt brakes onto; seconds is the time until it stops, or until a departure leaves the track.
Returns
Section titled “Returns”object
departing
Section titled “departing”departing:
boolean
moving
Section titled “moving”moving:
boolean
seconds
Section titled “seconds”seconds:
number|null
spawned
Section titled “spawned”spawned:
boolean
speed:
number
t:
number
target
Section titled “target”target:
number|null
halt()
Section titled “halt()”halt(
options?):boolean
Defined in: server/api.d.ts:4558
Brakes a moving train to a stop wherever that lands, never past the spot a moveTo was heading for (trainStopped).
Parameters
Section titled “Parameters”options?
Section titled “options?”Braking in m/s² (default 0.7, up to 10); Infinity stops it dead.
decel?
Section titled “decel?”number
Returns
Section titled “Returns”boolean
False when it is not moving, is already leaving the track, or for a bad decel.
moveTo()
Section titled “moveTo()”moveTo(
at,options?):boolean
Defined in: server/api.d.ts:4544
Runs the train from wherever it is, standing or moving, and brakes it to a stop on the spot (trainStopped). A spot too close to brake for at decel brakes harder. Replaces a running move or departure.
Parameters
Section titled “Parameters”string | number
t (0..1) or a stop id, at or ahead of the engine.
options?
Section titled “options?”speed: cruise in m/s (default 20, the game’s own; up to 60). accel: m/s² pulling away (default 0.5). decel: m/s² braking (default 0.7). accel and decel up to 10.
accel?
Section titled “accel?”number
decel?
Section titled “decel?”number
speed?
Section titled “speed?”number
Returns
Section titled “Returns”boolean
False with no train, a spot behind the engine, a departure already leaving the track, or bad options.
spawn()
Section titled “spawn()”spawn(
at?):boolean
Defined in: server/api.d.ts:4536
Stands the train at a spot, replacing one already out (trainEnded “despawned” for it), and fires trainSpawned.
Parameters
Section titled “Parameters”string | number
t (0..1) or a stop id. Defaults to 0.
Returns
Section titled “Returns”boolean
False for a t out of range or an unknown stop.
Properties
Section titled “Properties”length
Section titled “length”
readonlylength:number
Defined in: server/api.d.ts:4524
Metres of track from t = 0 to t = 1.
readonlystops:object[]
Defined in: server/api.d.ts:4529
Named spots along the track. hogsmeade stops the train along the station’s platform.
id:
string
t:
number