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

FSXA XML element variable Y position script

Roy Holmes

Resource contributor
Messages
1,805
Country
us-virginia
I would like to be able to vary the "Y" position of an element according to a variable input.

The SDK, Creating XML Gauges document, XML Gauge Reference section under "Element Objects" has a "TopScript" property which appears to be what I want.

However, I'm not using the ACES tool, I hand code.

I'm working on a gunsight reticle which is made up of diamonds drawn using polygons. Here is a code snippet
Code:
<Element>
			<Position X="323" Y="180"/>
			<Element>
				<Polygon Color="Red" LineWidth="1" FillColor="Red" Bright="Yes">
					<Point X="0" Y="-50"/>
					<Point X="-4" Y="-55"/>
					<Point X="0" Y="-60"/>
					<Point X="4" Y="-55"/>
					<Point X="0" Y="-50"/>
				</Polygon>
			</Element>

There are more polygons below that and the original element call is terminated with a close element.

As you can see the Y position is at 180 and this is what I would like to be able to change according to a L:var for sight depression.

I was wondering if something like this would work
Code:
<Position X="323" Y="180" Top=(L:Depression,number)/>

If I could do that I would avoid having to use a bunch of repeated code with discrete depression intervals according to visible conditions.

Roy
 
Last edited:
Roy, unfortunately many of the really cool things in that document such as "TopScript" will only work in an FSX XML Schema gauge file.

On the other hand, if the actual polygon never changes size but is simply shifted up/down based on some controllable parameter, why not simply USE a <Shift> section?

Here is an example of an "airplane" icon being shifted in both the X and Y directions, and rotated as well!

Code:
<!-- ======================= SMALL AIRPLANE:  DRAW =========================== -->
<Element>
	<Position X="316" Y="245"/>
	<Visible>(L:G1000 TOPO,enum) 1 ==</Visible>
	<Clip/>
	<Polygon FillColor="White" Bright="Yes">
		<Axis X="11" Y="16"/>
		<Point X="15.5" Y="0"/>
		<Point X="18" Y="3"/>
		<Point X="19" Y="12"/>
		<Point X="31" Y="17"/>
		<Point X="31" Y="19"/>
		<Point X="18" Y="19"/>
		<Point X="18" Y="28"/>
		<Point X="22" Y="32"/>
		<Point X="22" Y="34"/>
		<Point X="9" Y="34"/>
		<Point X="13" Y="28"/>
		<Point X="13" Y="19"/>
		<Point X="0" Y="19"/>
		<Point X="0" Y="17"/>
		<Point X="12" Y="12"/>
		<Point X="13" Y="3"/>
	</Polygon>
	<Rotate>
		<Value>(@g:currentPageNAV) @kNAVPageDflt == if{ 0 } els{ (A:GPS GROUND TRUE TRACK, Radians) }</Value>
	</Rotate>
	<Shift>
		<Value>
			(@g:currentGroup) @kNAVPageGroup == if{ 0 } els{ 140 }
		</Value>
		<Scale X="-1"/>
	</Shift>
	<Shift>
		<Value>(@g:currentPageNAV) @kNAVPageDflt == if{ -150 } els{ 0 }</Value>
		<Scale Y="-1"/>
	</Shift>
</Element>

Something like this perhaps, where (L:Depression,number) is the discrete number of pixels to shift up/down:
Code:
<Element>
  <Position X="323" Y="180"/>
  <Element>
    <Polygon Color="Red" LineWidth="1" FillColor="Red" Bright="Yes">
      <Point X="0" Y="-50"/>
      <Point X="-4" Y="-55"/>
      <Point X="0" Y="-60"/>
      <Point X="4" Y="-55"/>
      <Point X="0" Y="-50"/>
    </Polygon>
    <Shift>
      <Value>(L:Depression,number)</Value>
      <Scale Y="1"/>
    </Shift>
</Element>
 
Last edited:
Bill,
Thanks so much.
Must be getting old because I have two instances of the reticle and the first one for air to air shifts according to GForce inputs and rolls according to bank. Why I did not think of changing GForce for depression in the second instance beats me.

That is why I love this forum, If I can't see the wood for the trees, someone else can!

Thanks again

Roy
 
Back
Top