Skip to content

tw.light

Side: Client

Dynamic light sources with smooth intensity and position easing transitions.

Functions

tw.light.create(coords, intensity?, rgb?, range?, ease?)

Creates a dynamic light at the given world coordinates.

ParameterTypeDefaultDescription
coordsvector3World position
intensitynumber?1.0Light brightness
rgbtable?{255, 160, 122}Color as {r, g, b} (0-255)
rangenumber?10.0Light radius
easeinteger?1000Easing transition duration in ms

Returns: LightInstance — An object with methods to control the light.

LightInstance methods

:setCoords(coords)

Moves the light to new coordinates with easing.

ParameterTypeDescription
coordsvector3New world position

:setIntensity(intensity)

Changes the light intensity with easing.

ParameterTypeDescription
intensitynumberNew brightness value

:delete()

Removes the light source.

Examples

Create a campfire light

lua
local light = tw.light.create(
    vec3(-301.62, 783.04, 117.75),
    1.5,
    {255, 140, 50},
    12.0,
    800
)

Move a light smoothly

lua
local light = tw.light.create(vec3(100.0, 200.0, 50.0))

-- Move to a new position (eases over the configured duration)
light:setCoords(vec3(105.0, 200.0, 50.0))

Dim and delete

lua
-- Dim the light
light:setIntensity(0.2)
Wait(1000)

-- Remove it
light:delete()

Notes

  • All property changes (position, intensity) are eased over the duration set at creation (ease parameter).
  • The default color {255, 160, 122} is a warm light salmon tone, suitable for lanterns and campfires.
  • Lights are rendered every frame internally — you do not need to call anything in a loop.

Premium RedM Scripts — Multi-Framework