Light <BadgeClient/>
Light is a powerful module to create and manage dynamic light sources with smooth transitions in your RedM script. It allows for easily creating, moving, and fading lights with full control over color, intensity, and range.
::: tip Tips for using lights :
- Performance: Lights are relatively expensive to render. Keep the number of active lights to a minimum.
- Range: Smaller light ranges (5-15 units) often look better and are more efficient.
- Transitions: The
easeparameter allows for smooth transitions when changing properties, creating more natural-looking effects. - Colors: Different colors create different moods - warm colors (orange, yellow) for fires, cool colors (blue, cyan) for magical effects, etc.
:::
JO Functions > jo.light.create()
<!-- @include: ./slots/headers.md#client|jo.light.create -->
Creates a new light with the given properties <br>
<!-- @include: ./slots/descriptions.md#client|jo.light.create -->
JO Functions > jo.light.create() > Syntax
jo.light.create(coords, intensity, rgb, range, ease)
JO Functions > jo.light.create() > Parameters
coords : vector3
The position where the light will be created
intensity : float <BadgeOptional />
The light intensity from 0.0 to 1.0 - default:1.0
rgb : table <BadgeOptional />
RGB color values as a table {r,g,b} - default:
{255, 160, 122}
range : float <BadgeOptional />
The range/radius of the light - default:10.0
ease : float <BadgeOptional />
Transition time in milliseconds - default:1000
JO Functions > jo.light.create() > Return Value
Type : LightClass
The created light object
<!-- @include: ./slots/examples.md#client|jo.light.create -->
<!-- @include: ./slots/footers.md#client|jo.light.create -->
LightClass Methods > LightClass:delete()
<!-- @include: ./slots/headers.md#client|LightClass:delete -->
Marks a light for deletion and starts fading it out <br>
<!-- @include: ./slots/descriptions.md#client|LightClass:delete -->
LightClass Methods > LightClass:delete() > Syntax
LightClass:delete()
<!-- @include: ./slots/examples.md#client|LightClass:delete -->
<!-- @include: ./slots/footers.md#client|LightClass:delete -->
LightClass Methods > LightClass:setCoords()
<!-- @include: ./slots/headers.md#client|LightClass:setCoords -->
Sets new target coordinates for the light <br>
<!-- @include: ./slots/descriptions.md#client|LightClass:setCoords -->
LightClass Methods > LightClass:setCoords() > Syntax
LightClass:setCoords(coords)
LightClass Methods > LightClass:setCoords() > Parameters
coords : vector3
The new target position
<!-- @include: ./slots/examples.md#client|LightClass:setCoords -->
<!-- @include: ./slots/footers.md#client|LightClass:setCoords -->
LightClass Methods > LightClass:setIntensity()
<!-- @include: ./slots/headers.md#client|LightClass:setIntensity -->
Sets new target intensity for the light <br>
<!-- @include: ./slots/descriptions.md#client|LightClass:setIntensity -->
LightClass Methods > LightClass:setIntensity() > Syntax
LightClass:setIntensity(intensity)
LightClass Methods > LightClass:setIntensity() > Parameters
intensity : float
The new target intensity from 0.0 to 1.0
<!-- @include: ./slots/examples.md#client|LightClass:setIntensity -->
<!-- @include: ./slots/footers.md#client|LightClass:setIntensity -->
LightClass Methods > LightClass:update()
<!-- @include: ./slots/headers.md#client|LightClass:update -->
Updates the light properties based on elapsed time <br>
<!-- @include: ./slots/descriptions.md#client|LightClass:update -->
LightClass Methods > LightClass:update() > Syntax
LightClass:update(deltaTime)
LightClass Methods > LightClass:update() > Parameters
deltaTime : float
Time elapsed since last update in ms
<!-- @include: ./slots/examples.md#client|LightClass:update -->
<!-- @include: ./slots/footers.md#client|LightClass:update -->