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: | ||
− | + | ''void'' '''lightstyle'''(''float'' layer, ''string'' sequence) | |
− | |||
− | + | == Usage == | |
− | + | 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 === | ||
+ | *''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; } }