• 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.

MSFS20 Change one Simvar when another changes

Messages
6
Country
unitedkingdom
I'm trying to add some logic for an aircraft mod such that when one simvar is changed (triggered by the user toggling a switch for example), I can change the value of another simvar.

I've tried looking at the SDK docs, and am thinking I might need an `<InputEvent>` , but I'm really struggling with how to go about this. Please can anyone point me in the right direction?
 
I'd use an <Update> function simply because it is the easiest method.

Write the value of the simvar to an L:var.

If the simvar is different from the L:var change the value of the other simvar. Write the new value of the simvar to the L:var.

For example:

Code:
            <Update Frequency = "10">
                (A:IS USER SIM,bool)
                if{
                    (A:LIGHT PANEL:1,number)
                    if{
                        (A:LIGHT POTENTIOMETER:6,percent) (&gt;L:LIGHT_UV_LEFT_POTENTIOMETER,number)
                    }
                    els{
                        0 (&gt;L:LIGHT_UV_LEFT_POTENTIOMETER,number)
                    }
                    (A:LIGHT PANEL:2,number)
                    if{
                        (A:LIGHT POTENTIOMETER:7,percent) (&gt;L:LIGHT_UV_RIGHT_POTENTIOMETER,number)
                    }
                    els{
                        0 (&gt;L:LIGHT_UV_RIGHT_POTENTIOMETER,number)                  
                    }
                }              
            </Update>

This simple function checks the values of the Light Panel 1 and 2 (which can be switched by the user by various key commands, this covers all those commands in one simple step) and updates L:vars for light potentiometers for display within the cockpit without altering the actual light potentiometers values.
 
OK, so I'm trying this, to set SMOKE ENABLE the same as PROP DEICE SWITCH:

XML:
<Update Frequency = "10">
    (A:IS USER SIM,bool)
    if{
        (A:PROP DEICE SWITCH,bool) (&gt;A:SMOKE ENABLE,bool)
    }             
</Update>

I think the update block is running ok, but I don't think it's setting SMOKE ENABLE

Ultimately, I'm wanting to set SMOKE ENABLE from a joystick button. Since it isn't mappable in the standard controls, I'm basically trying to repurpose the prop deice control
 
Are you sure the update block is running? It needs to be attached to a component. Some people write with old style coding and I don't think the update block works in those situations. I only write in the new behavior code style where you need to include the update in a component (ie attached to a part of the model) otherwise it won't work.

First, I am sure you have a [SMOKESYSTEM] block in the systems.cfg.

This code uses the master battery and it includes a dummy L:var to check it is actually running (see the status in the Windows/Behaviors/Local variables screen).

Code:
            <Update Frequency = "10">

                    (L:dummy,number) 1 + (&gt;L:dummy,number)
                    (A:ELECTRICAL MASTER BATTERY,bool)
                    if{
                        (A:SMOKE ENABLE,bool) !
                        if{
                            (&gt;K:SMOKE_TOGGLE)
                        }
                    }
                    els{
                        (A:SMOKE ENABLE,bool)
                        if{
                            (&gt;K:SMOKE_TOGGLE)
                        }
                    }
            </Update>

This code also avoids any possible flooding issues. Because the smoke variables are ALL AIRCRAFT it is possible to send too much data down the multiplayer tube if you keep updating it. Only update these variables when they are different and that will ensure there is no flooding of data.
 
Last edited:
Sorry, yes, I did have that update code nested inside a component block

Ahh, it was the [SMOKESYSTEM] block that I was missing, that appears to be working now. Thank you very much for your help!
 
Back
Top