M MY Multiplayer: Wiki
Side
Kind

createRectLight

Client

Creates a light that comes from a rectangle, like a panel or a lit window. The light exists on this client only.

light|false createRectLight(float x, y, z, float normalX, normalY, normalZ [, float radius = 8, color color = tocolor(255, 255, 255), float width = 1, float height = 1])

Parameters

NameTypeDescription
x, y, zfloatThe light's position in the world, three numbers or a vec3.
normalX, normalY, normalZfloatWhere the rectangle's face points. Three numbers or a vec3, finite and non-zero; it is normalised. The light shines only in front.
radiusfloatRange in metres, above 0 and up to 1000.default 8
colorcolorThree numbers r, g, b (integers from 0 to 255) or a tocolor value. Alpha is ignored.default tocolor(255, 255, 255)
widthfloatWidth of the rectangle in metres, from 0.01 to 100.default 1
heightfloatHeight of the rectangle in metres, from 0.01 to 100.default 1

Returns

The created light element, or false if it could not be created.

The width runs along a tangent made from the normal and the world's up axis; change it with setLightTangent. The barn doors start at 88 degrees and 0.2 metres, so they block nothing. A light outside the focused dimension or area is not drawn.

Example

local light = createRectLight(1481.0, -1771.0, 22.0, 0, -1, 0, 12, 200, 220, 255, 4, 0.5)
setLightIntensity(light, 3)
Coming from MTAMTA has no dynamic lights. To light a single frame without creating an element, use dxDrawRectLight.

See also