Light
Defined in: server/api.d.ts:2745
A server-owned point or spot light that every player in range renders, at a place or riding an entity.
Extends
Section titled “Extends”ServerEntity.ServerEntity
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Light(
id):Light
Defined in: server/api.d.ts:2750
Wraps a light entity id without creating one.
Parameters
Section titled “Parameters”number
Network id of the server entity to wrap.
Returns
Section titled “Returns”Light
Methods
Section titled “Methods”attachTo()
Section titled “attachTo()”attachTo(
entity,offset?,rotation?):boolean
Defined in: server/api.d.ts:2880
Makes the light ride an entity’s body on every client until detach, and destroys it with the entity. False for a missing entity or one of another kind.
Parameters
Section titled “Parameters”entity
Section titled “entity”ServerEntity
A player, NPC, creature, world object or character.
offset?
Section titled “offset?”Offset in cm in the entity’s frame, so it turns with it.
number
number
number
rotation?
Section titled “rotation?”Rotation in degrees relative to the entity, to aim a spot light.
pitch?
Section titled “pitch?”number
number
number
Returns
Section titled “Returns”boolean
destroy()
Section titled “destroy()”destroy():
boolean
Defined in: server/api.d.ts:2890
Destroys this light; every client removes it.
Returns
Section titled “Returns”boolean
detach()
Section titled “detach()”detach():
boolean
Defined in: server/api.d.ts:2885
Leaves an attached light where its entity is. False when it was not attached.
Returns
Section titled “Returns”boolean
lookAt()
Section titled “lookAt()”lookAt(
target):boolean
Defined in: server/api.d.ts:2872
Turns a placed light to shine at a point. False while it is attached or when the point is where the light is.
Parameters
Section titled “Parameters”target
Section titled “target”A world position.
number
number
number
Returns
Section titled “Returns”boolean
set(
options):boolean
Defined in: server/api.d.ts:2866
Changes several settings at once. False for a light that no longer exists.
Parameters
Section titled “Parameters”options
Section titled “options”The fields to change; x/y/z and pitch/yaw/roll move it unless it is attached.
Returns
Section titled “Returns”boolean
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world,map?):void
Defined in: server/api.d.ts:2916
Moves this entity into another virtual world, within a map: there it meets the players in the same world of the same map, so world N of a dungeon is one instance of it.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
string
The map it is in, as player.location().areaId names it; “Overland” or “” for the shared map. Left out, it stays in its current map.
Returns
Section titled “Returns”void
setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: shared.d.ts:82
Restricts replication to one player’s connection, within the usual range and visibility checks; null lifts it.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: shared.d.ts:74
Returns
Section titled “Returns”string
create()
Section titled “create()”
staticcreate(id,kind,options?):Light|undefined
Defined in: server/api.d.ts:2898
Creates or replaces a light that every player in range renders. Throws on a wrong type, an unknown kind, preset or name.
Parameters
Section titled “Parameters”string
Stable string id; creating again under it replaces the light.
"point" | "spot"
A point light shines all round, a spot light in a cone along its forward axis.
options?
Section titled “options?”Placement and settings.
Returns
Section titled “Returns”Light | undefined
destroy()
Section titled “destroy()”
staticdestroy(id):boolean
Defined in: server/api.d.ts:2904
Destroys the light stored under an id.
Parameters
Section titled “Parameters”string
The id passed to create.
Returns
Section titled “Returns”boolean
presets()
Section titled “presets()”
staticpresets():LightPreset[]
Defined in: server/api.d.ts:2909
HL’s own light fixtures, from a candle to a street lamp, for LightOptions.preset.
Returns
Section titled “Returns”Properties
Section titled “Properties”attachedTo
Section titled “attachedTo”
readonlyattachedTo:number
Defined in: server/api.d.ts:2790
Network id of the entity it rides, or 0 when placed.
color:
object
Defined in: server/api.d.ts:2800
Linear color 0-1; also takes a “#RRGGBB” sRGB string.
b:
number
g:
number
r:
number
drawDistance
Section titled “drawDistance”drawDistance:
number
Defined in: server/api.d.ts:2850
Distance in cm from the camera beyond which clients stop drawing the light (default 4000, the game’s own); 0 never culls. Changing it re-creates the light on clients.
enabled
Section titled “enabled”enabled:
boolean
Defined in: server/api.d.ts:2765
Whether the light is on.
fadeRange
Section titled “fadeRange”fadeRange:
number
Defined in: server/api.d.ts:2855
Distance in cm over which the light fades out before drawDistance (default 300).
readonlyid:number
Defined in: shared.d.ts:65
Network id, stable for the entity’s lifetime.
innerCone
Section titled “innerCone”innerCone:
number
Defined in: server/api.d.ts:2830
Spot: the cone, in degrees from the axis, inside which the light is at full strength (default 0).
intensity
Section titled “intensity”intensity:
number
Defined in: server/api.d.ts:2805
Brightness in candelas, 0-100000 (default 8). HL’s own fixtures run from a candle’s 1 to a street lamp’s 60.
readonlykind:"point"|"spot"
Defined in: server/api.d.ts:2755
“point” or “spot”; fixed at create.
outerCone
Section titled “outerCone”outerCone:
number
Defined in: server/api.d.ts:2835
Spot: the cone, in degrees from the axis, at whose edge the light falls to nothing (default 44).
position
Section titled “position”position:
Vector3
Defined in: shared.d.ts:67
World position. Read, call set(...), then assign back.
priority
Section titled “priority”priority:
"always"|"low"|"high"|"normal"
Defined in: server/api.d.ts:2780
Its rank in the game’s render-side light budget; “always” exempts it.
radius
Section titled “radius”radius:
number
Defined in: server/api.d.ts:2810
How far the light reaches, in cm (its attenuation radius), 1-100000 (default 1000).
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: shared.d.ts:69
Reads as a quaternion; assignments also accept Euler angles in degrees.
shadowQuality
Section titled “shadowQuality”shadowQuality:
"medium"|"low"|"high"|"epic"|"cinematic"
Defined in: server/api.d.ts:2775
The lowest shadow quality setting at which a player sees its shadows.
shadows
Section titled “shadows”shadows:
boolean
Defined in: server/api.d.ts:2770
Whether it casts shadows.
softSourceRadius
Section titled “softSourceRadius”softSourceRadius:
number
Defined in: server/api.d.ts:2820
In cm; widens only the shadow penumbra.
sourceLength
Section titled “sourceLength”sourceLength:
number
Defined in: server/api.d.ts:2825
In cm; stretches a point or spot source into a tube along its forward axis.
sourceRadius
Section titled “sourceRadius”sourceRadius:
number
Defined in: server/api.d.ts:2815
Radius of the emitting sphere in cm; a wider source softens shadows and highlights.
specular
Section titled “specular”specular:
number
Defined in: server/api.d.ts:2845
Strength of its specular highlights, 0-1 (default 1); 0 lights diffuse only.
readonlystate:StateBag
Defined in: shared.d.ts:71
This entity’s key/value state: the server writes it, and every client that can see the entity receives it. See StateBag.
streamRange
Section titled “streamRange”streamRange:
number
Defined in: server/api.d.ts:2795
Interest radius in cm, clamped to 100-100000; takes effect at the next interest refresh.
temperature
Section titled “temperature”temperature:
number
Defined in: server/api.d.ts:2760
Color temperature in Kelvin, 1700-12000; 0 leaves the color untinted.
readonlyttl:number
Defined in: server/api.d.ts:2785
Seconds until the server destroys it, or 0 when it lives until destroy.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:2860
The virtual world scripts put this entity in. Outside the shared map (Overland) replication combines it with the entity’s map, as it does a player’s.
volumetric
Section titled “volumetric”volumetric:
number
Defined in: server/api.d.ts:2840
How strongly it lights volumetric fog, 0-100 (default 1).