• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Calling multi-smoke entries

DragonflightDesign

Resource contributor
Messages
1,097
Country
northernireland
Given this in the aircraft.cfg file:
Code:
[SMOKESYSTEM]
smoke.0= -14.00, 0.00, 0.00, fx_dummy
smoke.1= -18.40,-0.29,-2.95, fx_AOA_red
smoke.2= -18.40,-0.29,-2.71, fx_AOA_green
smoke.3= -18.40,-0.29,-2.83, fx_AOA_amber
smoke.4= -66.00,-1.80, 0, fx_fsxba_smoke_w
smoke.5= -68.50,-1.80, 0, fx_F18_EG_Smoke_L_NORM
smoke.6= -68.50, 1.80, 0, fx_F18_EG_Smoke_R_NORM
smoke.7= -63.00,-1.80, 0, fx_F18_HeatShimmer_L
smoke.8= -63.00, 1.80, 0, fx_F18_HeatShimmer_R
How would you call the individual entries using execute_calculator_code? Bear in mind that I've never had any success in setting XML vars using execute_calculator_code so yes, this is a blatant request for an example of working code :cool:
 
I wouldn't use execute_calculator_code. I would use trigger_key_event to write (KEY_SMOKE_ON/OFF events) and aircraft_varget to read (use the index parameter to read the state of the desired channel).
 
@WarpD: SMOKE_ON/OFF, but how would you tell it to select the required smoke.x listing?

@JB3DG: That would be one way of doing it.

Brain kicked into gear about twenty minutes ago. Another way would be to wrap the smoke functions in an XML file (as per Fr. Bill's code in the topic https://www.fsdeveloper.com/forum/threads/independent-multiple-smoke-fx.14592/#post-94271) and then use register_named_variable to call the XML gauge as required. I really wanted to keep all code within the C-gauge, but this is likely to be the best solution.

I'd still like an answer to my base question if possible: an example of using execute_calculator_code to set an A:var using a K:var (or is it the other way round???).
 
Maybe something like this:
Code:
        char str[40];

        sprintf_s(str,40,"%d (>K:SMOKE_ON)",1);
        execute_calculator_code(str,NULL, NULL, NULL);
 
If that doesn't work at all... try this:

Code:
        char str[40];

        sprintf_s(str,40,"%d (>K:SMOKE_ON, number)",1);
        execute_calculator_code(str,NULL, NULL, NULL);
 
Well, the test code might be...
Code:
void selectSmoke(bool action, int number)
{
    char str[40];
    static int check = 0;

    if (action == true && check == 0)
    {
        check = 1;
        sprintf_s(str, 40, "%d (>K:SMOKE_ON, number)", 1);
        execute_calculator_code(str, NULL, NULL, NULL);
    }

    if (action == false && check == 1)
    {
        check = 0;
        sprintf_s(str, 40, "%d (>K:SMOKE_OFF, number)", 1);
        execute_calculator_code(str, NULL, NULL, NULL);
    }
    return;
}
..but for some reason the smoke turns itself off as soon as I turn it on o_O. Working on it...

[Edit] This didn't work either:
Code:
        sprintf_s(str, "%d%s", number, " (>K:SMOKE_ON)", 1);
        execute_calculator_code(str, NULL, NULL, NULL);
 
Last edited:
I've been using this forever and it works:

Code:
void    SetLVar_Bool(INT32 Var, string LVar)
{
    char cTemp[60];
    sprintf_s(cTemp, "%d%s", Var, LVar.c_str());
    PCSTRINGZ szString = cTemp;
    execute_calculator_code(szString, NULL, NULL, NULL);
}
...and the usage in my case:
Code:
SetLVar_Bool(MFDState->switch_MFD_ON_OFF, " (>L:TB_GenericVar_01,bool)");
Or, in your case:
Code:
SetLVar_Bool(1, " (>K:SMOKE_ON)");
Hope that helps...
 
Last edited:
Just so we're clear the '1' in this code:
Code:
sprintf_s(str, 40, "%d (>K:SMOKE_ON, number)", 1);
is the value being passed with the SMOKE_ON event. So if you want to trigger a different smoke entry... you would need to use a different number.
 
I used an XML gauge to enable multiple smoke effects.

A typical statement has this form:

N (>K:SMOKE_SET)

where N = the smoke.x number + 1
 
@Gypsy Baron: Generally I don't do XML unfortunately - I'm resolutely old-school pure-C code unless I can't avoid it. Then I usually mangle somebody else's XML code until it does what I want it to do :)

@WarpD @Misho: It looks like our MDL guys have told me what they intend to do, not what they have done. This could go a loooong way to explaining why things don't work... Update will follow.
 
Not to "beat a dead horse" but in a lot cases I've seen the programmer / "do it yourselfer" has never has checked the current smoke state prior to the command.
It's a virus in one forum - "use this" :banghead:
Suddenly exits don't work, other gauges suffer etc.. Flooding.

I wouldn't use execute_calculator_code. I would use trigger_key_event to write (KEY_SMOKE_ON/OFF events) and aircraft_varget to read (use the index parameter to read the state of the desired channel).
:)

Just to add a little, in XML, an excerpt from my code template library:
XML:
<!-- AIRCRAFT.CFG NOTES

[SMOKESYSTEM]
//smoke.0 = DO NOT USE
smoke.1 = 0.00,  0.00,  0.00,  EFFECT #1
smoke.2 = 0.00,  0.00,  0.00,  EFFECT #2
smoke.3 = 0.00,  0.00,  0.00,  EFFECT #3
etc..
smoke.99 = 0.00,  0.00,  0.00,  EFFECT #99

-->

<Macro Name="SMK_CTRL">
    if{ (A:SMOKE ENABLE:@1, bool) 0 == if{ @1 (>K:SMOKE_ON) } } els{ (A:SMOKE ENABLE:@1, bool) 0 != if{ @1 (>K:SMOKE_OFF) } }
</Macro>

<!-- THE MACRO CALL
ON, WHERE X IS THE SMOKE NUMBER IN AIRCRAFT.CFG
1 @SMK_CTRL(X)

OFF, WHERE X IS THE SMOKE NUMBER IN AIRCRAFT.CFG
0 @SMK_CTRL(X) :
-->

<!-- EXAMPLE, USING THE MACRO: A HEAT PLUME IF ENGINE 1 IS RUNNING ON SMOKE 9 -->
<Element Name="Engine 1 Heat Plume">
    <Select>
        <Value>
            (A:ENG COMBUSTION:1, bool) @SMK_CTRL(9)              
        </Value>
    </Select>
</Element>

<!-- EXAMPLE, CODED IN NORMAL STYLE: A HEAT PLUME IF ENGINE 1 IS RUNNING ON SMOKE 9 -->
<Element Name="Engine 1 Heat Plume">
    <Select>
        <Value>
            (A:ENG COMBUSTION:1, bool)
            if{
                (A:SMOKE ENABLE:9, bool) 0 ==
                if{
                    9 (>K:SMOKE_ON)
                }
            }
            els{
                (A:SMOKE ENABLE:9, bool) 0 !=
                if{
                    9 (>K:SMOKE_OFF)
                }  
            }
        </Value>
    </Select>
</Element>
 
Last edited:
I fell foul of that general problem in the early days. Doing a check before acting also speeds up code execution. Admittedly, the above test code is just a block check, but it is only test code.
 
Back
Top