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

Editing lightstyle

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''lightstyle'''(''float'' layer, ''string'' sequence)
+
====Syntax:====
 +
<code>void lightstyle(float style, string value)</code>
  
== Usage ==
+
Changes a light style in-game.  In stock Quake, this is used to make switchable lights.
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:====
 +
:<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.
  
=== Parameters ===
+
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!).
*''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 ==
+
In stock quake, this was used to create switchable lights by alternating between 'm' and 'z' values when triggered, but you can also use it to change light patterns or to fade lights on and off.
// This function toggles a light on and off
+
 
void UseLight()
+
There are 64 light styles, from 0 to 63. If the style is not strictly comprised in characters from a to z, the game may crash. Styles 32-62 are assigned by the light program for switchable lights.
{
 
    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]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)