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

G:Vars

Messages
160
Setting a G:var value -

1 (>G:Var1) ++

(G:Var1) ++

Can someone tell me the difference? What the extra entries are in the first example.( 1 (> ) as they both appear to increment G:Var1 by 1 .

Also how would I set a G:Var to a specific value.
For example in .NET or BASIC I can just use x=2 .

Thanks
 
Setting a variable to a specific value:

2 (>G:Var1)

sets the variable to 2. This is equal to 2 (>G:Var1)

So your first line sets the variable to 1 and then increments it (which means it's always 2). The second line only increments the variable each time (so the line's value is always increasing, if the G: variable is saved each time).

Hope this helps,
 
Last edited:
(G:Var1) ++
As stated, this would create a value that is Var1 incremented by one.
The new value is now sitting on top of the stack, ready to use.
In the example it hasn’t yet been used in any way.
And, Var1 still contains its original value.

(G:Var1) ++ (>G:Var1)
Adding this assignment would update Var1 with the new value.

...
 
Last edited:
Thanks, so just to clear up -

(G:Var1) 0 == - would test a newly created Gvar for 0 (default value)


if later I wanted to change it to 1 or back to 0 I could use
1 (>G:Var1) - and it retains that value

0 (>G:Var1) - and it retains that value

of if it was part of a if or els

{ 1 (>G:Var1) 100 * } - should result in 100
 
Last edited:
No...
...this:

{ 100 (>G:Var1) } - should result in 100
 
To explain further, in the last expression the G: variable now equals one but the entire expression now equals 0, in case you are doing anything with it (like including it in a Macro, etc.). As Bill states, you must use the (>G:Var1) format to change the value of the G: variable itself.

Edit - corrected value.

Hope this helps,
 
Last edited:
To explain further, in the last expression the G: variable now equals one but the entire expression now equals 100, in case you are doing anything with it (like including it in a Macro, etc.). As Bill states, you must use the (>G:Var1) format to change the value of the G: variable itself.

Hope this helps,

Further more :)

{ 1 (>G:Var1) 100 * } this expression equals 0, and (G:Var1) equals 1.

When a value is assigned to a variable, the variable receives the new value and is immediately removed from the stack. So in this case, before 100 * the stack is empty so any value * 0 (empty) is 0 :D
In Bill's example, { 100 (>G:Var1) } the expression is 0 and (G:Var1) equals 100

Going further-than-further, what removes data from the stack is the assignment per se, and NOT the fact that there is a variable receiving the value.

For example
{ 12 } the stack equals 12
{ 12 (> ) } the stack equals 0, an assigment (> ) was made to nothing, so the value is extracted and discarded.

{ 12 (>G:Var1) } the stack equals 0, an assigment (> ) was made to G:Var1 then the value is extracted but in this case is received by G:Var1 instead of being lost in the universe.

Tom
 
Think I've got it ......

If I wanted to set a Var so it triggers something else later on, but return a different value from the expression, I could use -

{ 1 (>G:Var2) 100 + } --- as this equates to - 0 + 100 = 100 but G:Var2 = 1

or

{ 1 (>G:Var2) 200 } --- 200 returned it being the last value on the stack but G:Var2 = 1


Geez Gvars are a PITA.


Thanks guys.
 
Last edited:
BTW, most people don't use many G: vars, since:

1. You can only have 9 or 10
2. They don't have a logical name
3. They are local to the gauge, and no information can be passed to other gauges
4. They reset their value at the slightest provocation (resizing the panel, etc.).

For those reasons, most people use more L: variables than G:.

Hope this helps,
 
PS. That said, L: variables work exactly the same way as G: variables do, in the context of the above discussion.
 
While Tom's explanation is technically correct, I find trying to fathom the intricacies of stack operations to be eye searing, and brain deadening... :eek:

Also, as Tom stated G: vars are really pretty useless since they don't actually distinguish what they are used for integrally.

If one is a crackerjack programmer and well versed on stack operations, they can and do lead to some pretty elaborate and fast calculations, but what they gain in speed and efficiency they lose in intelligibility!

For me, it's far simpler to see things this way:

THIS (value) shoved into (>) THAT (L:variable)

200 (>L:THAT,enum)
 
BTW, most people don't use many G: vars, since:

1. You can only have 9 or 10
2. They don't have a logical name
3. They are local to the gauge, and no information can be passed to other gauges
4. They reset their value at the slightest provocation (resizing the panel, etc.).

For those reasons, most people use more L: variables than G:.

Hope this helps,

But AI aircraft don't respond to L vars ( or K vars ), they do to G vars.
So it's lets you use them as triggers for different parts of code.
 
But AI aircraft don't respond to L vars ( or K vars ), they do to G vars.
So it's lets you use them as triggers for different parts of code.

I don't know where you got that idea, as AI aircraft most certainly do respond to Lvars... :confused:

I see this all the time when suddenly all of my SR22 AI aircraft will spawn wheel chocks if I set my user SR22's wheel chocks to be visible! Of course, if I were going to release an SR22 AI model to the public, I'd fix that issue, but for my own use it's just not that important... :rotfl:
 
Sorry for taking so long to reply, real life caught up with me LOL.

So this should work using L:Vars

<code>
(A:LIGHT NAV,bool)
if{ (L:RATO_VISIBLE,bool)
if{ 0 }
els{ (A:RADIO HEIGHT,feet) 1500 &lt;
if{ 1 }
els{ 1 (&gt;L:RATO_VISIBLE,bool) 0 } } }
els{ 0 }
</code>

Simple visibility check / set.

Do L:Vars reset to 0 when the aircraft goes inactive?
 
I think he means when the AI aircraft goes to "sleep". No, I don't think so, unless your L: variable is somehow tied to the Nav Lights, or similar variable.
 
Thanks guys.
I am assuming my usage of the L:Vars was correct?

The sintax is ok but I don't know where are you planning to use them. Tom Gibson suggests is for an AI, which I believe it's the case. In my previous message I was speaking of a regular aircraft's situation.

Tom
 
Yeah is for an AI aircraft, so guessing I will have to add a condition tied to the NAV lights to reset L:Var to 0 when it goes inactive (just in-case someone hangs around to see it do it's next flight)

Only other thing I am going to have to account for is a go around.
Maybe add a condition based on (A:ACCELERATION BODY Z,feet/sec) correct units?
 
Back
Top