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

FSX Read Instantaneous Value

TurboCompound

Resource contributor
Messages
190
Hi all, I've been working away at my XML journey, and I had an idea for some psuedo systems logic. In order for it to work, however, I need to be able to do something using FS9 syntax XML.

I know that you can use (>L:BlaBlaSomething, percent) to store a value. But I would like to store a single value in an LVar and have that value stay the same even after it's source changes.

For example, if I wrote (A: Eng 1 RPM) d (>L:My Eng 1 RPM), then My Eng 1 RPM will always be the same as Eng 1 RPM. How would I write it such that when I trigger a given variable, the value of Eng 1 RPM at that moment is written to My Eng 1 RPM?

Thanks
 
Code:
(L:Trigger_Variable,number) 1 ==
if{
(A:Eng 1 RPM) (>L:My Eng 1 RPM)
0 (>L:Trigger_Variable,number)
}

Whenever you set trigger_variable to 1 (by some other code) the if{ } statement will run and reset the trigger_variable.

You can use whatever condition you like instead of the trigger_variable.
 
Unfortunately, it doesn't seem to want to set the trigger to zero. I feel like the condition that initially sets the trigger to 1 in conflicting with it.
 
Well, without knowing what the initial condition is then we are just shooting in the dark here.

You will need to supply some more information on what the code is that triggers your given variable.

Here is some psuedo code but without knowing what it is you are doing it really is just guessing:

(Condition that triggers given variable) (given variable) == 0 &
if{
Any other code
1 (>given variable)
}

(Condition that resets the given variable) (given variable) == 1 &
{
0 (>given variable)
}


then later you can do this if you need:
(given variable) == 1
{
(A:eng 1 rpm) (>L:my eng 1 rpm)
}
 
Well the good news is that I found a more efficient way do do what I was trying to do, and now my psuedo simulation seems to be working.
 
Of course. What I wanted to do was read the instant value of P:Absolute Time, then constantly subtract that value from Absolute time to keep track of the time elapsed since the variable was triggered. Fortunately, I found another method somewhere else on the forum that uses FS's 18Hz Gauge refresh rate as a timer by constantly adding 1 to an LVar.
 
Of course. What I wanted to do was read the instant value of P:Absolute Time, then constantly subtract that value from Absolute time to keep track of the time elapsed since the variable was triggered. Fortunately, I found another method somewhere else on the forum that uses FS's 18Hz Gauge refresh rate as a timer by constantly adding 1 to an LVar.

That method, despite being very simple, is indeed the least efficient for getting elapsed time values.
In the wiki you will find some entries on Timers, including macros for setting and retrieving elapsed values using P:Absolute Time.

Tom
 
Of course. What I wanted to do was read the instant value of P:Absolute Time, then constantly subtract that value from Absolute time to keep track of the time elapsed since the variable was triggered. Fortunately, I found another method somewhere else on the forum that uses FS's 18Hz Gauge refresh rate as a timer by constantly adding 1 to an LVar.

Neither the simulation rate nor the paused state of the sim influence simple 18 Hz timers.
For that reason, I am a huge fan of Gerry's method for a timer.

I don't know in what context you need the timer, but here's an example for how it works. The value of "elapsed time" will increase in 1 second intervals, but other values are possible (preferably larger than 1 and divisible by 18).

Code:
(P:ABSOLUTE TIME, seconds) (L:START TIME, seconds) - 1 >
if{ (P:ABSOLUTE TIME, seconds) (>L:START TIME, seconds)
(L:Elapsed Time, number) ++ (>L:Elapsed Time, number)
}
 
Back
Top