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

Simple Switch

Messages
33
Country
unitedkingdom
Hi guys. Looking for your help again. I want to build a simple on/off switch to operate the smoke system from a virtual cockpit. Can you please point me in the right direction as to how to do this. I am familiar with FSDS, animating and inserting gauges, but can't work out how to actually make it operate in the vc. Does a switch need to be programmed as an xml file or am I missing something else? Thank you

Robert
 
Hey Robert,


First you would create a basic code that would do what you needed to do.

You would then animate the switch.

You would then open the Attach Tool and attach the MouseRect using the code you just created in the ModelDef.XML parts sheet.

Next, you would open the Animation Manager, set your Animation key frames, like zero to 50 (typical for switches) or zero to 100, etc. Find the name of the newly made Animation object code you created in the list in the Animation Manager and click Create.

Done... The switch should now work if everything is done correctly.

There are tons of 'samples' in the ModelDef file, and you can look up the code of what you need in the SDK. (This is all for FSX by the way). But, you can use the FS2004 SDK for the code you'll need to activate what you need.

I am posting an attached 'fictional' switch below that works a fictional heater in the aircraft.

Note: Lag will change 'speed' of the animation. 50 is fast, 160 is slow....... slow slow. 10 would be a blip and 300 would crawl....... really crawl.

You will need to create new GUID's for the top code (which locates in the top portion of the ModelDef parts sheet), and the code block (bottom part) will locate in the bottom portion of the ModelDef file.

The cool thing about the bottom code is that you can re-use it over and over for tons of different things (that are fictional). You just change out the L:var code string, repeat it three times in the code block, make sure its not used again in any other codes, and you just keep going.

Example L:var;
(L:F24 FRONT CABIN HEATER, bool)

Make sure you put something in the TooltipText section. That will be the mouse-over message.


There are tons of things you can do with switches in the ToolTips. You can read more on those in the SDK. I recommend the Prepar3D SDK.

Lastly... Before you do this, make a copy of your ModelDef in case you mess it up. Saves you time. I put all my 'new' codes in the tops of the two sections of the ModelDef. If you mess up your code, it messes up the entire ModelDef, so that when you export a model, 'none' of the animations work. So you need to diagnose your code till it all works. If you do 10 new codes and suddenly it doesnt work (nothing), then you need to go in and do 'alot' of diagnosing to try to find the needle in the haystack that is causing the issue. A single symbol or letter can wreck the XML sheet.

Code:
    <Animation name="f24_front_cabin_heater" guid="fc6cf956-db35-4464-8672-4a463cd95f4e" length="100" type="Sim" typeParam2="f24_front_cabin_heater" typeParam="AutoPlay" />



<PartInfo>
   <Name>f24_front_cabin_heater</Name>
      <Animation>
	<Parameter>
	  <Code>(L:F24 FRONT CABIN HEATER, bool) 100 *</Code>
 	  <Lag>160</Lag>
	</Parameter>
      </Animation>
   <MouseRect>
	<Cursor>Hand</Cursor>
   <TooltipText>Front Cabin Heater</TooltipText>
   <CallbackCode>
            (L:F24 FRONT CABIN HEATER, bool) ! (>L:F24 FRONT CABIN HEATER, bool)
   </CallbackCode>
   </MouseRect>
</PartInfo>



Bill
 
Last edited:
I recommend also using underscore characters in the L:var name. Why, one might ask?

Simple really. It allows you to double-click on the full L:var name for quicker copy/paste operations! :cool:

Code:
(L:[COLOR="Red"]F24_FRONT_CABIN_HEATER[/COLOR], bool)
 
Thanks guys. A lot to digest but I am keen to experiment with the help of my son who is young and understands these things. Cheers
 
Back
Top