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

FS2004 Auto Pilot

Messages
1,749
Country
unitedstates
Hey everyone!

I found a strange Problem with my Auto Pilot.
I made 4 different types of xml part codes that work
perfect. But when I use the keyboard shortcut it
turns the AP on and off but no animation!

I could put a couple of my xml samples up. But I think that
is not the issue. Do I need to use the default xml formula?

I also tried using..... switch_autopilot_master......no luck!

I will post my last try. I used the ...(A:AUTOPILOT_MASTER,BOOL)....no luck!

This code works perfect as long as you use the mouse!

<part>
<name>switch_auto_pilot</name>
<AnimLength>360</AnimLength>
<animation>
<parameter>
<sim>
<variable>AUTOPILOT MASTER</variable>
<units>bool</units>
<scale>50</scale>
</sim>
<lag>400</lag>
</parameter>
</animation>
<mouserect>
<cursor>Hand</cursor>
<help_id>HELPID_GAUGE_AUTOPILOT_MASTER</help_id>
<tooltip_id>TOOLTIPTEXT_AUTOPILOT_MASTER</tooltip_id>
<mouse_flags>LeftSingle+Wheel+MoveRepeat</mouse_flags>
<callback_code>
(A:AUTOPILOT_MASTER,BOOL)
0 (&gt;L:WingLeveler, bool) 0 (&gt;L:HeadingSelector, bool) 0 (&gt;L:Var26, bool)
0 (&gt;L:Var27, bool) 0 (&gt;L:Var28, bool) 0 (&gt;L:Var29, bool)
1 (&gt;L:XMLSND1,enum)
</callback_code>
</mouserect>
</part>

Thanks DG,
 
Last edited:
Fixed my problem

Fixed my problem

<callback_code>
(A:AUTOPILOT_MASTER,BOOL) ! (&gt;K:AP_MASTER, bool)
0 (&gt;L:WingLeveler, bool) 0 (&gt;L:HeadingSelector, bool) 0 (&gt;L:Var26, bool)
0 (&gt;L:Var27, bool) 0 (&gt;L:Var28, bool) 0 (&gt;L:Var29, bool)
1 (&gt;L:XMLSND1,enum)
</callback_code>


Weird Solution! But normal!!!

DG:)
 
This part does absolutely nothing at all:

(A:AUTOPILOT_MASTER,BOOL) !

This is the only part that does something:

(>K:AP_MASTER)

In general, you will never have a "read variable" (such as A:vars) in a mouse event...

...unless you need to use one as a pre-condition for which event among several options you need to use.

In other words, if one button is used for multiple functions (such as a soft-key on a GPS, PFD, MFD, etc.), then it would be required to have "read variables" as pre-conditions.
 
It did make a difference

Not sure why. But with that code it allows
the keyboard shortcut to toggle the switch.
that's why i said i fixed it.

Again everything works, except the keyboard shortcut only
clicks the switch with my added code.

But know i have another problem. It toggles
the switch off and works fine, but it does not
make all the othe pre conditions turn off other switches.
Unless you actually click the switch.


What could we add to make the everything work
from clicking to keyboard keys?

DG,
 
Understand that absolutely nothing in the mouse section is ever executed unless you use the mouse.

So no, using the keyboard will not run the XML script(s) in a mouse section.
 
Solution

Can we add pre conditions to
default codes without disturbing the structure?

I need some to add this: 1 (&gt;L:XMLSND2,enum)

This will allow me to have the lights work
with the mouse and keyboard. My custom does not do both.

I will remove that code I made. I agree it makes no sense
to put that type of variable in a mouse controlled area.
I relized it was not that code that finally made the switch
work from the keyboard. So yes that code does nothing:)

Thanks again DG,
 
Ah, I see. You want the "click" sound to be heard whether the mouse or the keyboard command is used...

You might try something like this (Tested*). It is a tiny gauge that may be loaded in the [VCockpit01] section, and hidden in the upper left corner:


Code:
<Gauge Name="MyLogic" Version="1.0">
  <Image Name="Transparent.bmp" />
  <Macro Name="AP_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="AP_MASTER">@AP_Click</On>
  </Keys>
</Gauge>

Transparent.bmp is a tiny 2x2 pixel bitmap with pure black color.

* NOTE: Well, I'll be darned! It actually works! :rotfl:
 
Last edited:
Update

I added the other pre conditions to this gauge
and everthing works. I feel I have a way better understanding
on how to share communication between default and custom.

Thanks a million!

<Gauge Name="Click" Version="1.0">
<Image Name="Transparent.bmp" />
<Macro Name="AP_Click">
0 (&gt;L:WingLeveler, bool) 0 (&gt;L:HeadingSelector, bool) 0 (&gt;L:Var26, bool)
0 (&gt;L:Var27, bool) 0 (&gt;L:Var28, bool) 0 (&gt;L:Var29, bool) 1 (&gt;L:XMLSND2,enum)
</Macro>
<Keys>
<On Event="AP_MASTER">@AP_Click</On>
</Keys>
</Gauge>

DG,
 
No problem. The reason I expressed "surprise" is that usually whenever I write script "off the cuff" it doesn't work right the first time... :D

BTW, when posting XML (or any code for that matter), please use the "codebox" instead of the "quotebox. The "codebox" is the # icon in the editor's toolbar.

This way the "indenting" is preserved, making it easier to read as well as copy/paste directly from the forum. Also, you will find it much easier if you keep each "command" on a new line, so they don't all run together into an incoherent mess... :rotfl:

Code:
<Gauge Name="Click" Version="1.0">
   <Image Name="Transparent.bmp" />
   <Macro Name="AP_Click">
       0 (&gt;L:WingLeveler, bool) 
       0 (&gt;L:HeadingSelector, bool) 
       0 (&gt;L:Var26, bool)
       0 (&gt;L:Var27, bool) 
       0 (&gt;L:Var28, bool) 
       0 (&gt;L:Var29, bool) 
       1 (&gt;L:XMLSND2,enum)
   </Macro>
   <Keys>
       <On Event="AP_MASTER">@AP_Click</On>
   </Keys>
</Gauge>

Also, you can add as many <On Event="xxx">'s as you need, and as many <@Macro Name="xxx"> sections as you wish.

Just one other suggestion: try to use "meaningful names" for your custom L:vars. Using numbers will just make tracing your logic more difficult if you need to do so months down the road. :twocents:

I tend to use names such as (L:KAP140_NavButton,bool) for example, so it will most likely never conflict with anyone else's L:var, and the prefix "KAP140_" tells me in which project this bit of scripted gauge is used.
 
Thanks

great info,

I do use a name instead of Var125.
But on some parts that have 5 or 6 of them
I like to use the var22 rather than name them.
But for 1 part, I use a name.

I have a question on the module i got from you.

I want to change this code to work from the
<variable>RUDDER PEDAL POSITION</variable>
rather than the click or hand events.
heres your original. I am lost on this one.
Also I will post what I added to my click gauge
you helped me make today. 2 x2 pixel.

Thanks for the tip on code box. let's try.
Code:
            <Cursor Type="Hand"/>
		<Click Kind="LeftSingle + RightSingle">
		  (M:Event) 'LeftSingle' scmp 0 ==  
		     if{ 1 (&gt;L:XMLSND3,enum) }

		  (M:Event) 'RightSingle' scmp 0 ==  
		     if{ 1 (&gt;L:XMLSND3,enum) }
		</Click>
         <Tooltip>SND 3</Tooltip>

Code:
<Gauge Name="Click" Version="1.0">



  <Image Name="Transparent.bmp" />
  <Macro Name="AP_Click">
    0 (&gt;L:WingLeveler, bool) 0 (&gt;L:HeadingSelector, bool) 0 (&gt;L:Var26, bool)
    0 (&gt;L:Var27, bool) 0 (&gt;L:Var28, bool) 0 (&gt;L:Var29, bool) 1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="AP_MASTER">@AP_Click</On>
  </Keys>



  <Image Name="Transparent.bmp" />
  <Macro Name="fuel_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="PITOT_HEAT_TOGGLE">@fuel_Click</On>
  </Keys>



  <Image Name="Transparent.bmp" />
  <Macro Name="recog_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="TOGGLE_RECOGNITION_LIGHTS">@recog_Click</On>
  </Keys>


  <Image Name="Transparent.bmp" />
  <Macro Name="cabin_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="TOGGLE_CABIN_LIGHTS">@cabin_Click</On>
  </Keys>



[COLOR="Red"]  <Image Name="Transparent.bmp" />
  <Macro Name="Pedals_POSITION">
    1 (&gt;L:XMLSND3,enum)
  </Macro>
  <Keys>
    <On Event="RUDDER_PEDAL_POSITION">@Pedals_POSITION</On>
  </Keys>[/COLOR]

</Gauge>

Not sure if this will work for taging the sound to the part?

Thanks DG
 
Last edited:
You can have one -and only one- <Keys> section. You also need only one background <Image> in your gauge:

Code:
<Gauge Name="Click" Version="1.0">
  <Image Name="Transparent.bmp" />
  <Macro Name="AP_Click">
      0 (&gt;L:WingLeveler, bool) 
      0 (&gt;L:HeadingSelector, bool)
      0 (&gt;L:Var26, bool)
      0 (&gt;L:Var27, bool) 
      0 (&gt;L:Var28, bool) 
      0 (&gt;L:Var29, bool) 
      1 (&gt;L:XMLSND2,enum)
  </Macro>
  
  <Macro Name="fuel_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  
  <Macro Name="recog_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  
  <Macro Name="cabin_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  
  <Macro Name="Pedals_POSITION">
    1 (&gt;L:XMLSND3,enum)
  </Macro>
  
  <Keys>
    <On Event="AP_MASTER">@AP_Click</On>
    <On Event="PITOT_HEAT_TOGGLE">@fuel_Click</On>
    <On Event="TOGGLE_RECOGNITION_LIGHTS">@recog_Click</On>
    <On Event="TOGGLE_CABIN_LIGHTS">@cabin_Click</On>
    <On Event="RUDDER_PEDAL_POSITION">@Pedals_POSITION</On>
  </Keys>
</Gauge>

I have no idea if the pedal position event will work or not. Some things you'll just have to discover for yourself... :D
 
okay

very nice.

I actually have more on that gauge but did not want to post
all of it. But i will use the proper formula. I had alot of keys.
What's the difference? Will the gauge read faster this way.

Man oh Man. I thought how to use the rudder pedals.
Might not figure that one out.

Is there any other events codes for adding sound that
you know of. I am good at mixing codes some times.
But I have no clue on writing a variable code.
So any type of formulas that might help on the rudder pedals
or yoke would be great! Like you said, might have to do it myself.

I will update you on any luck getting the pedals to work!

Thanks again DG,
 
Working

I actually got it to work the first time.

Code:
    <On Event="AXIS_RUDDER_SET">@Rudder_Percent</On>

Can you help me add a timer to a macro.
i tried and had no luck.

I need it to stay on for 4 to 6 seconds.
It constantly restarts the sound as you move the pedals.

Thanks DG,
 
Maybe this might be of help:

http://www.fsdeveloper.com/wiki/index.php?title=XML:_Timer

Although it might be that FS won't choke on multiple <Key> entries, for the purpose of clarity and ease of maintenance it only makes sense to have only one such section.

I do know from bitter experience that FS will not allow us to have multiple <Update> sections, which truly sucks because sometimes it would be convenient to have different bits of script executing under different schedules, i.e., some things updating every second, others updating every five seconds, etc.
 
Well, this is the FS-Developer Wiki, and that entry didn't even exist until you asked the question...

It is something that I had planned to post about a year ago, but somehow never got around to it... :rotfl:
 
Thanks

Thanks for adding that.

Well I don't think I will be able to make
an axis controlled sound.

Thanks for all the help.

DG,

Update:

I got it working so the left pedal activates one sound
and the other pedal plays another sound.

I got a timer to activate the gauge, but have no clue
on how to control the time. I probably have a messy code!

I managed to make this with no Macro.


Code:
<Gauge Name="Sound" Version="1.0">

<Element>
	<Select>
		<Value>
			(A:RUDDER DEFLECTION,grads) 
			(L:SoundTime,bool) 5 &lt;
			and
				if{
				(L:SoundTime,bool) ++ (>L:SoundTime,bool) }
		</Value>
	</Select>
</Element>

<Element>
	<Select>
		<Value>
			(A:RUDDER DEFLECTION,grads) 
			(L:SoundTime,bool) 5 &gt;
			and
				if{
				(L:SoundTime,bool) ++ (>L:SoundTime,bool) }
		</Value>
	</Select>
</Element>

<Element>
    	<Select>
    	 	<Value>
       		(L:SoundTime,bool) ! if{ (A:RUDDER DEFLECTION,grads) (>G:Var1) }
     	 	</Value>
   	</Select>
</Element>

<Element>
    	<Select>
     	 	<Value>
       			(L:SoundTime,bool)  if{ (G:Var1) (A:RUDDER DEFLECTION,grads) -  5 &gt; if{ 1 (&gt;L:XMLSND2,enum) } }
       			(L:SoundTime,bool)  if{ (G:Var1) (A:RUDDER DEFLECTION,grads) - -5 &lt; if{ 1 (&gt;L:XMLSND3,enum) } }
     	 	</Value>
   	</Select>
</Element>

</Gauge>

Any tips or help would be awsome!

DG,
 
Last edited:
Back
Top