C: FX driver using aircraft.cfg smoke entries: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
(Using the [smoke] entries to run fx) |
m (Added INFOBOX Applicable-FSVersion. Corrected CATEGORY to appropriate version(s)) |
||
| Line 1: | Line 1: | ||
{{Infobox-Applicable-FSVersion | |||
| MSFS2024 = unknown | |||
| MSFS2020 = unknown | |||
| FSXI = unknown | |||
| P3D5 = true | |||
| P3D4 = true | |||
| P3D3 = unknown | |||
| P3D2 = unknown | |||
| P3D = unknown | |||
| FSW = unknown | |||
| FSXSE = true | |||
| FSXA = true | |||
| FSX = true | |||
| FS2004 = unknown | |||
| FS2002 = unknown | |||
| XP11 = unknown | |||
| XP10 = unknown | |||
| XP9 = unknown | |||
}} | |||
There are 99 available [smoke] entries available in the aircraft.cfg file and they don't have to be smoke-style fx; they can be any type of fx you like. One of the more common usages is to drive fx that are being used for aircraft lighting. The following function is a simple method of having a one-line fx driver: | There are 99 available [smoke] entries available in the aircraft.cfg file and they don't have to be smoke-style fx; they can be any type of fx you like. One of the more common usages is to drive fx that are being used for aircraft lighting. The following function is a simple method of having a one-line fx driver: | ||
| Line 36: | Line 56: | ||
setFX(true, landing_lights) // Landing lights on | setFX(true, landing_lights) // Landing lights on | ||
[[Category: Aircraft Design]] [[Category: Panel and Gauge Design | [[Category: Aircraft Design]] [[Category: Panel and Gauge Design]] | ||
Latest revision as of 14:31, 25 May 2024
| Applicable |
|---|
| MSFS2024 |
| MSFS2020 |
| MS Flight |
| LM P3D5 |
| LM P3D4 |
| LM P3D3 |
| LM P3D2 |
| LM P3D |
| FS World |
| FSXSE |
| FSXA |
| FSX |
| FS2004 |
| FS2002 |
| XP11 |
| XP10 |
| XP9 |
There are 99 available [smoke] entries available in the aircraft.cfg file and they don't have to be smoke-style fx; they can be any type of fx you like. One of the more common usages is to drive fx that are being used for aircraft lighting. The following function is a simple method of having a one-line fx driver:
void setFX(bool action, int number)
{
// Assign a character string
char fx_number[20];
// Ensure the string is clean
memset(fx_number,0,20);
// Set the fx to 'on'
if (action == true)
{
sprintf_s(fx_number, 20, "%d (>K:SMOKE_ON)", number);
execute_calculator_code(fx_number, NULL, NULL, NULL);
}
// Set the fx to 'off'
if (action == false)
{
sprintf_s(fx_number, 20, "%d (>K:SMOKE_OFF)", number);
execute_calculator_code(fx_number, NULL, NULL, NULL);
}
return;
}
In you code you call it by
setFX(true, 14)
where 'action' is true (on) or false (off) and the number is the corresponding entry in the aircraft.cfg file. To make your code easier to read you can assign a description to the fx number e.g.
const int landing_lights = 14;
so the call then becomes
setFX(true, landing_lights) // Landing lights on