Page tree
Skip to end of metadata
Go to start of metadata

"Lights" are invisible objects that emit light, which will brighten up the surrounding area.

Before V3.2 only omni-directional lights (lightpoints that illuminate all directions) could be created with these commands. Uni-directional lights (e.g. "spotlights", as on vehicle headlights) were only available inside models.
Since V3.2 a light object can be turned into spotlights via the setLightType command.

Lights are only visible in dark conditions.

Lights in a mission cannot be detected via allStaticVehicles.
The command nearestObjects though, is able to find them if filtering for "#lightpoint", e.g.

_lights = nearestObjects [player,["#lightpoint"],500]

Green light, with red ambient color, attached to player

// lightpoint is created 
_light = "#lightpoint" createVehicleLocal (getPos player);
// the color of the lightpoint itself is green 
_light setLightColor [0,1,0];
// the ambient color of the light is red
_light setLightAmbient [1,0,0];
// light's brightness is set to 20% (maximum is 1)
_light setLightBrightness .2;
// light is attached to player (3m above him), so it will move with him
_light lightAttachObject [player,[0,0,3]];

Light and ambient color effects

// color definitions for light and ambient
_colors = [

_pos = player modelToWorld [5,10,0];

for "_i" from 0 to (count _colors)-1 do {
  // create a pole
  _pole = "Land_poleend" createVehicle _pos;
  // create a light, and attach it to pole
  _light = "#lightpoint" createVehicle _pos;
  _light lightAttachObject [_pole,[-.5,0,3.5]];
  // set the light and ambient colors, as well as the brightness
  _light setLightColor ((_colors select _i) select 0);
  _light setLightAmbient ((_colors select _i) select 1);
  _light setLightBrightness .15;
  // move on to the next position
  _pos set [1,(_pos select 1)+40];

Rotating spotlight

_light = "#lightpoint" createVehicle (player modelToWorld [0,5,1.5]); // create a light
_light setLightType 1; // make it a spotlight
_light setLightColor [1,0,0]; // set its color
_light setLightBrightness 1; // and brightness

_col = 0; _dir = 0;
while {true} do { // endlessly rotate
  _dir = if (_dir<360) then {_dir + 2} else {2};
  _light setDir _dir; // set spotlight direction
  if ((_dir mod 90)==0) then {
    _light setLightColor [_col,0,1-_col]; // switch light color every 90º
    _col = 1-_col;
  sleep .0001;

Demo mission for color settings