• 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 Very basic question

Messages
27
Country
us-newhampshire
Hello,

I am getting my hands dirty with XML gauges. I have Cabin Comfort example working. Now I am trying to move a rectangle element on the screen. For simplicity I have only two elements. One is a text and the second is a rectangle, which I am trying to position. I have a variable (C:CABIN:PassengerComfort). It's values is shown in the text, so I can see that my dll properly updates the variable value. Now comes the part I struggle with. I want to use LeftScript and TopScript scripts for the rectangle element to move it. Here is the example of my code. The first element shows the value as a string (0 to 100), which works properly. But the second element does not move at all (it should move diagonally). I suspect that I simply wrote the scripts wrongly. Can you believe it, just one variable and no operations? What am I doing wrong there?
Code:
<Element id="Element">
	<FloatPosition>120.000,115.000</FloatPosition>
	<GaugeText id="GaugeText">
		<Bold>True</Bold>
		<FontColor>yellow</FontColor>
		<FontHeight>11</FontHeight>
		<GaugeString>%((C:CABIN:PassengerComfort))%!3.0f!</GaugeString>
		<HorizontalAlign>RIGHT</HorizontalAlign>
		<Size>80,13</Size>
		<Transparent>True</Transparent>
	</GaugeText>
</Element>
<Element id="Element">
	<FloatPosition>110.000,35.000</FloatPosition>
	<LeftScript>(C:CABIN:PassengerComfort,number)</LeftScript>
	<TopScript>(C:CABIN:PassengerComfort,number)</TopScript>
	<Rectangle id="Rectangle">
		<LineWidth>1</LineWidth>
		<Width>20</Width>
		<Height>20</Height>
		<LineColor>yellow</LineColor>
		<FillColor>yellow</FillColor>
	</Rectangle>
</Element>

In the c++ code PassengerComfort is a number.

Thanks a lot.
 
Try taking the floatposition element out of the rectangle, then adding the values you would have used onto the rectangle. You're meant to use Top/Left Script in replacement for floatposition, not with. That might work.
 
Try taking the floatposition element out of the rectangle, then adding the values you would have used onto the rectangle. You're meant to use Top/Left Script in replacement for floatposition, not with. That might work.

Thanks. The documentation says that Script values will overwrite the floatposition. I also found this thread, which says that these scripts only work to modify the initial value. I need to use Shift to move the rectangle. I sill do not clearly understand how I can modify X and Y with Shift. Shift allows me to set a single value, but I need both X and Y...

Thanks.
 
As I said in that thread, it's hard to think of a more throughly useless set of tags.

You can have multiple <Shift> expressions within the same <Element>

The first <Shift> can be constrained to the X axis.

The second <Shift> is made a child of the first <Shift> and is constrained to the Y axis.
 
Thanks, n4gix. I understand that I need to use shift objects. The only question is how to do it properly. I started with this script. The script displays a filled rectangle I want potentially to move (first element) and a rectangle border, just to see if the gauge is displaying at all. The script works. I see two rectangles...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<SimBase.Document Type="AceXML" version="1,0" id="MyGauge">
    <Descr>MyGauge</Descr>
    <Filename>MyGauge.xml</Filename>
    <SimGauge.Gauge id="Gauge" ArtDirectory="">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Size>225,145</Size>
        <Element id="Element">
            <FloatPosition>10,10</FloatPosition>
            <Rectangle id="Rectangle">
                <LineWidth>1</LineWidth>
                <Width>20</Width>
                <Height>20</Height>
                <LineColor>yellow</LineColor>
                <FillColor>yellow</FillColor>
            </Rectangle>
        </Element>
        <Element id="Element">
            <FloatPosition>5.000,5.000</FloatPosition>
            <Rectangle id="Rectangle">
                <LineWidth>2</LineWidth>
                <Width>214</Width>
                <Height>134</Height>
                <LineColor>yellow</LineColor>
            </Rectangle>
        </Element>
    </SimGauge.Gauge>
</SimBase.Document>
Now the next step is to add shift command. I looked at other scripts in gauges that came with FSX and it uses a different format <Gauge> instead of <SimBase.Document> as the root element. That is why expect it is not exactly the same. Anyways, even if I add:
Code:
<Element id="Element">
    <FloatPosition>10,10</FloatPosition>
    <Rectangle id="Rectangle">
    <Shift>
         <Script>(A:Aileron trim pct,percent)</Script>
     </Shift>
...
For my first rectangle, then no rectangles are shown and I assume that the gauge was not loaded. I tried adding all the properties described in the documentation:
Code:
    <Shift id="SomeId">
         <Minimum>0</Minimum>
         <Maximum>100</Maximum>
         <Script>10</Script>
     </Shift>
I have nothing on the screen. What am I doing wrong here? Thanks a lot.
 
Understand first that I don't do XML scripts using the FSX schema...

...with that said, the basic format for a <Shift...> is:

Code:
                    <Element id="Right Indicator">
                        <FloatPosition>0.000,0.000</FloatPosition>
                        <Shift id="Shift">
                            <Expression id="Expression">
                                <Script>(A:FUEL RIGHT QUANTITY, gallons)</Script>
                            </Expression>
                            <NonlinearityTable id="NonlinearityTable">
                                <NonlinearityEntry id="0">
                                    <ExpressionResult>0.000</ExpressionResult>
                                    <FloatPosition>0.000,0.000</FloatPosition>
                                </NonlinearityEntry>
                                <NonlinearityEntry id="75">
                                    <ExpressionResult>75.000</ExpressionResult>
                                    <FloatPosition>110.000,0.000</FloatPosition>
                                </NonlinearityEntry>
                            </NonlinearityTable>
                        </Shift>
                        <Element id="Polygon">
                            <FloatPosition>0.000,0.000</FloatPosition>
                            <Polygon id="Polygon">
                                <Bright>True</Bright>
                                <FillColor>White</FillColor>
                                <FillColorScript>@FuelQty2Caution if{ &apos;Yellow&apos; }
                                    els{
	                                    @FuelQty2Warning if{ &apos;Red&apos; }
	                                    els{ &apos;White&apos; }
                                    }</FillColorScript>
                                <LineWidth>1</LineWidth>
                                <LineColor>Black</LineColor>
                                <Point id="0, 0">
                                    <FloatPosition>0.000,0.000</FloatPosition>
                                </Point>
                                <Point id="5, 3">
                                    <FloatPosition>5.000,3.000</FloatPosition>
                                </Point>
                                <Point id="5, 13">
                                    <FloatPosition>5.000,13.000</FloatPosition>
                                </Point>
                                <Point id="-5, 13">
                                    <FloatPosition>-5.000,13.000</FloatPosition>
                                </Point>
                                <Point id="-5, 3">
                                    <FloatPosition>-5.000,3.000</FloatPosition>
                                </Point>
                            </Polygon>
                        </Element>

In your example, you are mixing FS9 XML schema with FSX XML schema. That will never work.

Note that in the above example, there is a Nonlinearity table entry that defines how many pixels to shift the drawn polygon up/down per/gallon.
 
Thanks, n4gix. Your example clarified how to use shift. Now I do have my square moving in X and Y direction. Thanks a lot!
Code:
<Element id="Element">
	<FloatPosition>110.000,35.000</FloatPosition>
	<Shift id="Shift">
		<Expression id="Expression">
			<Script>(C:MyGauge:XPos, number)</Script>
		</Expression>
		<NonlinearityTable id="NonlinearityTable">
			<NonlinearityEntry id="0">
				<ExpressionResult>0.000</ExpressionResult>
				<FloatPosition>0.000,0.000</FloatPosition>
			</NonlinearityEntry>
			<NonlinearityEntry id="75">
				<ExpressionResult>75.000</ExpressionResult>
				<FloatPosition>110.000,0.000</FloatPosition>
			</NonlinearityEntry>
		</NonlinearityTable>
	</Shift>
	<Shift id="Shift">
		<Expression id="Expression">
			<Script>(C:MyGauge:YPos, number)</Script>
		</Expression>
		<NonlinearityTable id="NonlinearityTable">
			<NonlinearityEntry id="0">
				<ExpressionResult>0.000</ExpressionResult>
				<FloatPosition>0.000,0.000</FloatPosition>
			</NonlinearityEntry>
			<NonlinearityEntry id="75">
				<ExpressionResult>75.000</ExpressionResult>
				<FloatPosition>0.000,75.000</FloatPosition>
			</NonlinearityEntry>
		</NonlinearityTable>
	</Shift>
	<Rectangle id="Rectangle">
		<LineWidth>1</LineWidth>
		<Width>20</Width>
		<Height>20</Height>
		<LineColor>yellow</LineColor>
		<FillColor>yellow</FillColor>
	</Rectangle>
</Element>
 
You are most very welcome. As I said, since I "roll my own" XML in Visual Studio, I don't bother much with the overly complicated and excessively verbose FSX XML schema.

There are really only two functions* that the FSX XML schema offers beyond that of FS9, and frankly they have easy work-around-equivalents using FS9's simpler syntax.

* New Functions:
dynamic arc drawing
dynamic pie drawing
 
Back
Top