IndicatorLights syntax overview - KSPSnark/IndicatorLights GitHub Wiki
What is IndicatorLights syntax?
A primary goal of IndicatorLights is to make it very flexible and useful to modders: specifically, to make it easily possible to achieve just about any desired effect, just by tinkering with config files, without requiring writing any code.
IndicatorLights achieves this via a simple but powerful text language for "color source" syntax, which allows describing how a light gets its color based on a variety of functional sources.
What does it look like?
Here's what it looks like in action (taken from the science lab config):
MODULE {
name = ModuleCrewIndicator
emissiveName = indicator1
toggleName = indicatorToggle
pilotColor = blink(dim($CrewPilot, 0.7), 150, $Off, 650)
engineerColor = blink(dim($CrewEngineer, 0.7), 150, $Off, 650)
scientistColor = ModuleConverterIndicator
touristColor = blink(dim($CrewTourist, 0.6), 150, $Off, 650)
}
...those fields toggleName
, pilotColor
, engineerColor
, scientistColor
, and touristColor
are all examples of IndicatorLights syntax.
What are the types of syntax?
Everything in IndicatorLights has an inherent data type. There are four data types available:
- Color source: This is the most frequently used type. It defines a thing that has an output color that can be used to control an emissive mesh or meshes on a part.
- Scalar: This is an object that has a single, floating-point scalar output value, which may dynamically change at run time.
- Static: This is a special case of scalar. It's a numeric value that's evaluated just once, at module start time, and the calculated value is then stored and used thereafter.
- Toggle: This is an object that has a single boolean output value, which may dynamically change at run time.
How do I use them?
Every IndicatorLights expression that takes parameters will always require that each parameter be specifically one of the above data types.
Note that "which type is this?" depends on context. For example, the string "ModuleResourceLevelIndicator" could represent a color source, a scalar, or a toggle, depending on the context where it's used.
Each of these four different types has its own specific syntax. For detailed documentation of each one, please see the relevant page:
How can I debug this?
The extreme flexibility of IndicatorLights syntax lets you achieve a wide variety of visual effects... but the complexity can make it tricky to fine-tune exactly the appearance you want, or to figure out what's going wrong if it looks different from what you expected.
Wouldn't it be nice if there were a tool where you could just type in some syntax, and immediately see it on-screen so that you can judge the results and tweak it as needed?
Fortunately, there is! Please see the IndicatorLights debug console documentation.