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

LVar - have I got this code right? (SOLVED )

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
Hi folks, currently melting what brain cells I have left in a crash-course in XML coding. This is probably child's play for many but I wanted to see if I've got my understanding of Lvars and how they work correct before I go meddling too much.

What I need to do = have an MFD screen for weapons in the VC, upon which the user can press a mouse rect for a particular weapons station. The screen icon for that weapon lights up, and the weapon also appears on the station on the external model and in the VC.

As I understand it, via much reading here and elsewhere, I can put an LVAR code in the modeldef.xml that will call the Lvar I create, plus another for the mouse rect, and then call that code in the MFD gauge XML.

Here's the code - if anybody passing through here sees any major cock ups, or knows I'm chasing rainbows with this entire idea, feel free to let me know and save me the agony :)

The LVar and mouse rect in modeldef.xml;

Code:
    <PartInfo>
    <Name>Weapon Visible</Name>
        <Visibility>
            <Parameter>
                <Code>
                (L:Weapon1,bool)
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

    <PartInfo>
        <Name>Weapon Invisible</Name>
        <Visibility>
            <Parameter>
                <Code>
                (L:Weapon1,bool) !
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

<PartInfo>
  <Name>Weapon1 Load</Name>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <CallbackCode>
      (L:Weapon1,bool) ! (>L:Weapon1,bool)
    </CallbackCode>
  </MouseRect>
</PartInfo>

Would this type of method also work for switching screens in the same MFD, between things like radar screen, weapons screen and so on? It seems most folks use Lvars for that purpose, but I'm struggling to understand the numbering process.
 
Messages
113
Country
unitedstates
Hi, Deano,
I don't know a bloody thing about working with .mdl files and MCX, although I am obviously going to have to learn sooner or later.
Having said that, I've been working with Jimi and the guys at the FSDT FSX Blue Angels team on their awesome F/A-18C, for FSX. I've been working on adding the HARM missile into the TacPack setup for the plane. They set up the model file for me, so I can make the missiles appear and disappear on certain stations on the wings, using the Configurator used for TP. As well, I've gotten a couple MFD screens for the HARM (AGM-88) set up.
I've gotten the missiles to lock and fire under the proper circumstances. Having said all that, I'm struggling with getting the system to switch screens, automatically switch weapons systems and so on when the RWR (RHAW gear) detects a site painting your plane.

In any event, it sounds like you're working on something similar. Switching MFD screens, and so on. The plane already had all that coded in, in an xml file that's part of the panel.cfg set of files. I just need to do my little bit of the whole thing. Sadly, a lot of xml programing is still new to me, but I'm learning. I thought you might get some ideas from what's already been done in this bird, using all the different L:Vars, A:Vars etc.
The plane is free to DL and install, all you need is do is register on their forum, again, free and easy. Once you have the autoinstaller, you can "install" the plane into the folder of your choice, and look through the model, and panel, files to see how they did what they did. I don't mean duplicate their work for your own use, but maybe how they did what they did will give you some helpful ideas on how to do what you want to do, if that makes any sense.
You can DL the plane from HERE. Make sure you download the right plane for your sim: FSX/P3Dv3, or P3DV4 and up. The download links are about 1/2 way down the post, easy to find and clearly labeled as to what sim they're for. Look in the Panel.Fleet folder, Avionics subfolder. The XML files for the DDI's are in the folder named, oddly enough, DDIs.
You don't need TP to be able to study the xml files, just to make the weapons function at all.

Hope this all helps a little...
Pat☺
 

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
Hi Pat, many thanks for taking the time to reply,

I'll take a look, but there are quite a few airplanes out there which use either FS9 or FSX schema to switch screens and so on. My own F-18E won't be Tacpacked, as VRS have all that covered nicely, but it'll be nice to have the selectable weapons in play for different visual load-outs. I've spent loads of time reading the XML work of others, learning how and why they've done certain things and trying to emulate as I learn, if that makes sense. Much of what I've learned has come from reading posts here going back years, especially Bill Leaming's advice and examples, of which he's made about four billionty :)

I was just looking for a little confirmation really - I've learned that it's very easy to end up going down a rabbit whole trying endless different codes, when in fact I was right the first time but for a single missing comma, or a space added where there shouldn't have been one, things like that. Very frustrating, to say the least!

Anyway, I think I'm about on the right tracks so will probably end up giving my codes a whirl soon and see how they perform...
 
Messages
176
Country
unitedkingdom
Deano
The freeware Non-TacPack F-35 has the features you require, you'll need to use XMLTools or equivalent.


"- All variants: Weapons loaded on stores will now actually induce drag.
- All variants: For Non-TacPack users, a Weapons Configurator to easily set/view the weapons loadout instead of using the manual payload settings."
 

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
@Essex Thank you very much, I'll take a look at that, it sounds like just what I'm after on the ordnance side of things :)
 
Messages
244
Country
england
You don't need the "weapon invisible" entry. The Lvar is a Boolean, so if it's 1 the weapon will show, otherwise it's hidden, unless you want something else to show if the weapon is hidden.
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Your XML scripts are perfectly written. Dave is quite correct in this instance the 'weapon invisible' script isn't needed. All that remains for you is implementation in the model itself.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
I use Visual Studio to create/edit XML scripts. I keep a Templates.xml file handy from which I can quickly grab - well - simple templates I can use and fill in the blanks, such as
XML:
<Animation name="" guid="" length="" type="Sim" typeParam2="" typeParam="AutoPlay" />

  <PartInfo>
    <Name>PartName</Name>
    <AnimLength>5</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:somevarname,bool) 5 *
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <CallbackCode>
        (L:somevarname,bool) ! (>L:somevarname,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
Mmmm - nothing's working, in true time-honoured FS fashion. Codes added to modeldef.xml file, visibility conditions added to a fuel tank for testing purposes. No problems there. Applied the code into an MFD screen xml as below;

Code:
<Element>
<Position X="256" Y="256"/>
<Select>
<Value>(L:Weapon1, bool)</Value>
<Case Value="1">
<Image Name="Tank.bmp" ImageSizes="100,50"/>
</Case>
</Select>
</Element>


<Mouse>

<Area Left="256" Top="256" Width="50" Height="100">
<Cursor Type="Hand"/>
<Click Event="Weapon1 Load" Repeat="No"/>
<Tooltip>CTR TANK</Tooltip>
</Area>

</Mouse>

My little tank image doesn't appear, and neither does the external tank model. I just haven't got my head around how the syntax works to call the Lvar I've created. Piccy below of the cockpit and the tooltip showing in the left MFD - considering how I've managed to learn to code all the other far more complex things, it's a pain to be brought up short on a "simple" visibility issue! Could anybody put me right please? :)
 

Attachments

  • F18F_VC.png
    F18F_VC.png
    2 MB · Views: 178

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
OK, I've established that an Lvar cannot be assigned to a click "event" of any kind, but then how can a mouse click area reference the LVar and trigger the visibility of the weapon and the screen icon? :rolleyes:
 

Deano1973

Resource contributor
Messages
384
Country
unitedkingdom
SOLVED!! :D

Code:
<Element>
<Position X="245" Y="187"/>
<Select>
<Value>(L:Weapon1, bool)</Value>
         <Case Value="1">
            <Image Name="Tank.bmp" ImageSizes="50,100"/>
         </Case>
</Select>
</Element>


<Mouse>

<Area Left="245" Top="187" Width="50" Height="100">
<Cursor Type="Hand"/>
<Click Kind="LeftSingle">(L:Weapon1,bool) ! (>L:Weapon1,bool)</Click>
<Tooltip>CTR TANK</Tooltip>
</Area>

</Mouse>

Got there in the end through a bit of trial and error - thanks for all the advice folks!
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Just to complete the theory of operations:
XML:
(L:Weapon1,bool) ! (>L:Weapon1,bool)
What the ! operates in this instance is simply as a toggle. It takes the (L:var,unit) and inverts it's value. If it is zero, then clicking will give a value of one. Clicking again makes it zero again.
Ya just can't get much simpler than this! :teacher:
 
Messages
7
Country
argentina
Excuse me gentlemen I finally don't understand what is the assignment for the tank modeling (code) writing inside modeldef xml.
Visibility --------- Unnecessary.
Mouse ---------------- Correct.
I apologize for the poor reasoning!
Thanks a lot!!!
 
Top