Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "lightstyle"

From Quake Wiki

(Created page with "====Syntax:==== <code>void lightstyle(float style, string value)</code> Changes a light style in-game. In stock Quake, this is used to make switchable lights. ====Parameters...")
 
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
====Syntax:====
+
''void'' '''lightstyle'''(''float'' layer, ''string'' sequence)
<code>void lightstyle(float style, string value)</code>
 
  
Changes a light style in-game.  In stock Quake, this is used to make switchable lights.
+
== Usage ==
====Parameters:====
+
Changes the current lighting sequence on the passed light layer. Any lights using that layer will have their lighting changed, so unique layers should be used for decoupled lights. 0 is the default light layer for most lights, so it's usually best to avoid changing this one.
:<code>style</code> - The light style to affect.
 
:<code>value</code> - The string of letters that make up the lightstyle's brightness values.
 
====Returns:====
 
:void
 
====Example:====
 
lightstyle(15, "azazaaazzz");
 
====Other Details:====
 
The string '''value''' is a sequence of letters representing different brightness levels.
 
'''a''' is pitch black (off) and '''z''' is full brightness (in engines with overbright lighting, this is actually double brightness, '''m''' is normal brightness).
 
Each letter is played for 0.1 seconds and when the engine gets to the end of the sequence, it loops back to the beginning.
 
It is important to note that a light style is global and will affect all lights in the level that are tagged with a particular light style.  Setting style 0 will affect all normal lights in the level (including sunlight and minlight!).
 
  
 +
=== Parameters ===
 +
*''layer''
 +
:The light layer to modify. This can be a value from 0 to 63. Layers 32 to 62 are used for toggleable lights.
 +
*''sequence''
 +
:The lighting sequence to apply. This must be a character from "a" to "z". "a" is minimum brightness while "z" is maximum brightness. "m" is considered normal lighting. By combining multiple characters an animation sequence can be made for the lights. This animates at 10 FPS meaning a sequence of <code>"abcdefghijkm"</code> will go from pitch dark to normal lighting in 1.1 seconds. This loops infinitely so care should be taken into what the light does after reaching the end of the sequence.
 +
 +
== Example ==
 +
// This function toggles a light on and off
 +
void UseLight()
 +
{
 +
    if (self.spawnflags & LIGHT_OFF)
 +
    {
 +
        lightstyle(self.style, "m");
 +
        self.spawnflags &= ~LIGHT_OFF;
 +
    }
 +
    else
 +
    {
 +
        lightstyle(self.style, "a");
 +
        self.spawnflags |=  LIGHT_OFF;
 +
    }
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:32, 1 August 2023

void lightstyle(float layer, string sequence)

Usage[edit]

Changes the current lighting sequence on the passed light layer. Any lights using that layer will have their lighting changed, so unique layers should be used for decoupled lights. 0 is the default light layer for most lights, so it's usually best to avoid changing this one.

Parameters[edit]

  • layer
The light layer to modify. This can be a value from 0 to 63. Layers 32 to 62 are used for toggleable lights.
  • sequence
The lighting sequence to apply. This must be a character from "a" to "z". "a" is minimum brightness while "z" is maximum brightness. "m" is considered normal lighting. By combining multiple characters an animation sequence can be made for the lights. This animates at 10 FPS meaning a sequence of "abcdefghijkm" will go from pitch dark to normal lighting in 1.1 seconds. This loops infinitely so care should be taken into what the light does after reaching the end of the sequence.

Example[edit]

// This function toggles a light on and off
void UseLight()
{
    if (self.spawnflags & LIGHT_OFF)
    {
        lightstyle(self.style, "m");
        self.spawnflags &= ~LIGHT_OFF;
    }
    else
    {
        lightstyle(self.style, "a");
        self.spawnflags |=  LIGHT_OFF;
    }
}