Skip to main content

Lighttweener

Based on game build 714014 | Last updated: 2026-03-03

Overview

LightTweener provides linear interpolation (tweening) for dynamic lighting effects. It modifies the visual properties of a light component attached to the same entity over a specified duration. This component is used to create smooth transitions between lighting states—such as dimming, brightening, or shifting colour—commonly seen in ambient effects, ambient alerts, or event-driven environmental changes.

Usage example

local inst = CreateEntity()
inst:AddComponent("lighttweener")

local light = inst:AddChild()
light:AddComponent("light")
light:GetComponent("light"):SetRadius(3)
light:GetComponent("light"):SetIntensity(0.5)
light:GetComponent("light"):SetFalloff(1.0)
light:GetComponent("light"):SetColour(1, 1, 1)

inst.components.lighttweener:StartTween(
light, -- light to tween
5, -- target radius
1.0, -- target intensity
0.5, -- target falloff
{0.8, 0.2, 0.2}, -- target colour (red-ish)
2.0, -- duration in seconds
function() print("Tween finished!") end -- callback
)

Dependencies & tags

Components used: None identified
Tags: None identified

Properties

PropertyTypeDefault ValueDescription
instEntitynilReference to the entity that owns this component.
lightLightComponent or nilnilThe light component being tweened.
i_falloff, i_intensity, i_radiusnumber or nilnilInitial (start) values for light properties.
i_colour_r, i_colour_g, i_colour_bnumber or nilnilInitial RGB colour components.
t_falloff, t_intensity, t_radiusnumber or nilnilTarget (end) values for light properties.
t_colour_r, t_colour_g, t_colour_bnumber or nilnilTarget RGB colour components.
callbackfunction or nilnilFunction called when tween completes.
timenumber or nilnilTotal duration of the tween in seconds.
timepassednumber0Time elapsed since tween started.
tweeningbooleanfalseWhether a tween is currently in progress.

Main functions

StartTween(light, rad, intensity, falloff, colour, time, callback)

  • Description: Begins a tween operation on the specified light, interpolating its properties from current values to target values over time seconds. If time is 0, the tween completes immediately.
  • Parameters:
    • light (LightComponent) — The light component to animate.
    • rad (number or nil) — Target radius.
    • intensity (number or nil) — Target intensity.
    • falloff (number or nil) — Target falloff.
    • colour (table or nil) — Table of {r, g, b}; values expected in [0, 1] range.
    • time (number) — Duration in seconds.
    • callback (function or nil) — Function to call upon completion, receiving (inst, light) as arguments.
  • Returns: Nothing.
  • Error states: Returns early and prints a warning if light is nil or not provided; sets self.light but skips updating if unset.

EndTween()

  • Description: Immediately sets the light to its final (target) values and stops the update loop.
  • Parameters: None.
  • Returns: Nothing.
  • Error states: No-op if self.light is nil.

OnUpdate(dt)

  • Description: Updates the tween per frame by linearly interpolating between initial and target values. Called automatically while tweening is true.
  • Parameters:
    • dt (number) — Time in seconds since last frame.
  • Returns: Nothing.
  • Error states: Prints warning and stops updates if self.light is nil. Automatically calls EndTween() when timepassed >= time.

Events & listeners

  • Listens to: None.
  • Pushes: None.