FSDeveloper Community

Go Back   FSDeveloper Community > Microsoft Flight Simulator development > Aircraft Design > Modeling

Modeling Use this forum for all your modelling related discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 20 Jan 2012, 03:30
mile high mile high is offline
  australia
Join Date: Sep 2008
Posts: 51
Needed XML code script for an AI canopy cover

Hi friends,

I'm trying to place a canopy cover on my freeware FS2004 AI aircraft model that I developed in FSDS 3.5.1 but I only wish to have the canvas cover over the canopy glass at night.
I have tried several xml codes but nothing so far seems to work for me, can any of the xml guru's that understand this stuff help me out please.

Can anybody see where this script may be incorrect!

Thanks,

<part>
<name>YOURPARTNAME</name>
<visible_in_range>
<parameter>
<code>(A:TIME OF DAY, enum)</code>
</parameter>
<minvalue>2</minvalue>
<maxvalue>3</maxvalue>
</visible_in_range>
</part>
Reply With Quote
  #2  
Old 02 Feb 2012, 17:46
delivery guy's Avatar
delivery guy delivery guy is offline
  unitedstates
Location: California
Join Date: Jan 2010
Posts: 638
you need to specify one of the 3 choices.

General time of day:
1 = Day
2 = Dusk/Dawn
3 = Night

<code>(A:TIME OF DAY:3, enum)</code>

or

<code> 3 (A:TIME OF DAY, enum)</code>

Try this
Reply With Quote
  #3  
Old 02 Feb 2012, 18:23
tgibson tgibson is offline
  us-california
Location: San Diego
Join Date: Sep 2006
Posts: 3,200
Actually his code is correct. You do not put the value as an index (:3). What's probably wrong is it should be E:, not A:. It is an Environment variable, not an Aircraft variable.

Hope this helps,
__________________
Tom Gibson
CalClassic Propliners
http://www.calclassic.com
Reply With Quote
  #4  
Old 02 Feb 2012, 19:59
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Code:
<part>
     <name>YOURPARTNAME</name>
     <visible_in_range>
          <parameter>
               <code>(E:TIME OF DAY, enum)</code>
          </parameter>
          <minvalue>2</minvalue>
          <maxvalue>3</maxvalue>
     </visible_in_range>
</part>
__________________
Bill Leaming
3d Modeler Max/GMax
C & XML Gauge Programmer
Eaglesoft Development Group
http://eaglesoftdg.com

Intel® Core™ i7-3770k 4.2GHz - Crucial 16GB DDR3 - Dual Radeon HD770 1GB DDR5 (Crossfire) - Eco II Watercooling - Win7 64bit
Intel® Core™ i7-2600k 3.4GHz - Crucial 4GB DDR3 - NVIDIA GeForce GTX550Ti 1GB - Win7 64bit
Intel® Core™ i7-860 2.8GHz - Crucial 8GB DDR3 - NVIDIA GeForce GTS240 1GB - Win8 64bit
NOTE: Unless explicitly stated otherwise, everything written by my hand is MY opinion. I do NOT speak for any company, real or imagined...
Reply With Quote
  #5  
Old 07 Feb 2012, 08:24
mile high mile high is offline
  australia
Join Date: Sep 2008
Posts: 51
Thanks guy's for the reply and confirmations, the "e" made all the difference and is working a treat. A bunch of new freeware AI models will be using this code to delight fellow simmers.

Cheer's,

Mark
Reply With Quote
  #6  
Old 09 Aug 2012, 09:09
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Just noticed this while looking for ideas about canopies masking out aircraft parts for no good reason.

I know this is a late response, but is a canopy by time of day a good idea? What if the AI flight plan gets the aircraft airborne at a time when the canopy is still there?

I'm still trying to get the crew to vanish when the AI is inactive, and surely the canopy would be better conforming to that idea instead.
Reply With Quote
  #7  
Old 09 Aug 2012, 15:01
tgibson tgibson is offline
  us-california
Location: San Diego
Join Date: Sep 2006
Posts: 3,200
I assumed that this part was linked to other parts that had the proper visibility tags to avoid it being present when the aircraft was flying.

For AI aircraft to display something when inactive, something like this works well:

Code:
<part>
  <name>ground_equipment</name> <!-- for AI aircraft -->
  <visible_in_range>
  <parameter>
  <code> (A:LIGHT BEACON, bool) (A:VELOCITY BODY Z, knots) 0 != || </code>
  </parameter>
  <minvalue>-1</minvalue>
  <maxvalue>0</maxvalue>
  </visible_in_range>
  </part>
So inverting the logic of the code line should give you what you want:

Code:
<part>
  <name>cockpit_crew</name> <!-- for AI aircraft -->
  <visible_in_range>
  <parameter>
  <code> (A:LIGHT BEACON, bool) ! (A:VELOCITY BODY Z, knots) 0 == &amp;&amp; </code>
  </parameter>
  <minvalue>-1</minvalue>
  <maxvalue>0</maxvalue>
  </visible_in_range>
  </part>
Hope this helps,
__________________
Tom Gibson
CalClassic Propliners
http://www.calclassic.com

Last edited by tgibson; 17 Aug 2012 at 13:49. Reason: Added missing equals sign
Reply With Quote
  #8  
Old 10 Aug 2012, 03:05
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Quote:
Originally Posted by tgibson View Post
I assumed that this part was linked to other parts that had the proper visibility tags to avoid it being present when the aircraft was flying.
Ah, I'll be getting into that area once I sort out my vanishing flap problem, so I may be able to use an adaptation on that code snippet (using "LIGHT NAV" to unhide the crew, I hope, since nav lights come on when the aircraft comes out of sleep and may be the only way to determine that it is active).

Maybe something like

<part>
<name>cockpit_crew</name> <!-- for AI aircraft -->
<visible_in_range>
<parameter>
<code> (A:LIGHT NAV, bool) ! 0 = &amp;&amp; </code>
</parameter>
<minvalue>-1</minvalue>
<maxvalue>0</maxvalue>
</visible_in_range>
</part>

Last edited by Here for the Beer; 10 Aug 2012 at 03:10.
Reply With Quote
  #9  
Old 10 Aug 2012, 13:38
tgibson tgibson is offline
  us-california
Location: San Diego
Join Date: Sep 2006
Posts: 3,200
True for jets and turboprops, but nav lights for piston aircraft come on when the engine starts (on my computer, anyway), which occurs *after* pushback. So I would have no crew in the plane as it pushes back.
__________________
Tom Gibson
CalClassic Propliners
http://www.calclassic.com
Reply With Quote
  #10  
Old 11 Aug 2012, 02:47
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Quote:
Originally Posted by tgibson View Post
True for jets and turboprops, but nav lights for piston aircraft come on when the engine starts (on my computer, anyway), which occurs *after* pushback. So I would have no crew in the plane as it pushes back.
Thanks, Tom, I had no idea different types were coded differently WRT the lights, although it makes sense from a real-world PoV, where we GA people only load up the electrics after we're got the ability to generate some power for them that isn't a big battery more useful for engine starts.

First I'll be investigating why nav lights don't show when the a/c operates as AI, since it might affect that phase of development anyway. My job for today...
Reply With Quote
  #11  
Old 11 Aug 2012, 06:59
Flusirainer Flusirainer is offline
  germany
Join Date: Mar 2010
Posts: 146
Quote:
First I'll be investigating why nav lights don't show when the a/c operates as AI, since it might affect that phase of development anyway. My job for today.

Has AI_Aircraft only one engine, functions not the NAV_Light.


aircraft.cfg (example: Jet)


before

[GeneralEngineData]
engine_type= 1
Engine.0= -18.200, 0.000, 0.800
fuel_flow_scalar= 1.000
min_throttle_limit = -0.2


[jet_engine]
thrust_scalar =1.000


after

[GeneralEngineData]
engine_type= 1
Engine.0= -18.200, 0.000, 0.800
Engine.1= -18.200, 0.000, 0.800
fuel_flow_scalar= 1.000
min_throttle_limit = -0.2


[jet_engine]
thrust_scalar =0.500


And this is the configuration of my AI_MiG-21 UM / AI_MiG-21 US(MakeMDL.parts.xml)



Canopy
Code:
<part>
	<name>Kanzel_Haube</name>
	<animation>
		<parameter>
			<code>
                       (E:TIME OF DAY, enum) 1 ==
                        if{
                           (A:LIGHT NAV, percent) 50 &gt; 
                           (A:LIGHT CABIN, percent) 50 &gt; and
                                   if{ 100 } els{ 0 }
                          }
                       els{
                           (A:LIGHT NAV, percent) 50 &gt; 
                           (A:LIGHT BEACON, percent) 50 &lt; and
                           (A:LEFT WHEEL RPM, rpm) -0.001 &gt; and
                                   if{ 100 } els{ 0 }
                          }
                         </code>
                        <lag>25</lag>
		</parameter>
        </animation>
</part>

Pilot
Code:
<part>
	<name>Pilot</name>
	<visible_in_range>
		<parameter>
			<code>
                       (E:TIME OF DAY, enum) 3 ==
                        if{
                           (A:LIGHT BEACON, percent) 50 &gt;
                           (A:LEFT WHEEL RPM, rpm) 0 &lt; or
                                  if{ 1 } els{ 0 } 
                          }
                       els{
                           (A:LIGHT NAV, percent) 50 &gt; 
                           (A:LIGHT CABIN, percent) 50 &lt; and
                                  if{ 1 } els{ 0 }
                          } 
                 </code>
		</parameter>
		<minvalue>1</minvalue>
        </visible_in_range>
</part>
The cabin lights switches off 6 seconds before clearance. But only when TIME OF DAY = 1
During other options, it is always turned on.

parking


10 minutes before clearance (NAV_LIGHT on)



taxing

Last edited by Flusirainer; 11 Aug 2012 at 07:11.
Reply With Quote
  #12  
Old 11 Aug 2012, 10:19
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Wow Rainer, you're a life-saver. I was about to waste days trying to figure out the lights thing and you just gave me those days back to do, well, house decorating in fact... hmm.

I wonder if FS is as full of these idiosyncratic things as it seems - one engine = no nav lights? How counter-intuitive is that? I'd not have figured that one out in a month of Sundays because I try to apply logic to things. I wouldn't even have found that one by my normal searching (in fact I only got back to this post because I did a google search web-wide for a solution and it brought up this thread).

In light of what Tom mentioned (about recip engines vs jets and how they use their lights) I would need to adopt Tom's code or adapt yours, but so long as it does the job to some degree, I'm okay with that. I will still think "around the code" and see whether I can possibly get the pilot showing up sooner, but I'm well aware that there are more informed minds than mine on top of the subject. Many thanks again for such great help.

Edit: I added in another engine entry and the performance is a lot better (it was pretty sluggish in some flight modes), but the nav lights still aren't there even when airborne as AI. I have some more experimenting to do.

Last edited by Here for the Beer; 11 Aug 2012 at 11:54. Reason: Experimented with lights
Reply With Quote
  #13  
Old 12 Aug 2012, 11:15
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
I tried returning the Vans to 1 engine since it should be okay. The nav lights are not working for some reason, but I don't think it is a lack of spare engines. There are other GA planes in my setup that have single engine entries and working lights. In fact I'm considering moving my contact points over to a copy of the default Mooney CFG and working up from there, from scratch.

The removal of the pilots when inactive is failing too, so I'm considering making a cockpit cover that comes off after pushback, or something similarly compromised. I will scour the XML for errors, since I assume an error above the code for the canopy can just as easily stop it from being used.
Reply With Quote
  #14  
Old 15 Aug 2012, 06:18
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Trying out Tom's code for the crew, I can make them vanish when the aircraft is running, but the inverse logic is evidently different. I've done a few experiments around the code and have managed hybrids (visibility responding to lights but not movement etc) but have run out of time now. I'm not a fan of reverse Polish notation at the best of times, but I suspect there's some problem with inverting the conditions and the tests too.

Visible if lights or movement
Invisible if no lights and no movement (not either).

Either that or the visibility range needs to be shifted to reflect the results of the tests. If adding together 2 falses do we end up with -2 (&&) or does the logic say "they are 2 boolean results, therefore the answer is -1 because they're both false, so the overall condition is false".

I spent a day believing that grouped and/or animated items were perhaps immune to these XML operations, which is why I made the canopy - partly to test the theory.

I'd still prefer the crew to vanish (fewer polys to display when inactive - and the crew have a lot of polys for their size), so I'll come back to this later. The nice thing is that by sensible naming of the crew components, at least the same snip of XML can apply to them both.

Ugh. Anyway, have to get the car in to the garage now...they managed to unfix it while they were fixing it yesterday. I think in logic terms that comes out to zero. And it's raining.

Edit: I was on my way out and had a small thought, went back in and tried it out. I'll post the changed stuff later, but suffice to say my changes worked on both crew. If you call teh XML ai_pilot and have your crew as ai_pilot_01 and ai_pilot_02, the same code is good for them both. When I'm away from the computer I just think about the logic and not about experimentation, and I think that makes all the difference. Anyway, to the garage... oh joy.

Last edited by Here for the Beer; 15 Aug 2012 at 07:20. Reason: Went back and tried one more option, and it worked.
Reply With Quote
  #15  
Old 15 Aug 2012, 13:09
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
Code:
<part>
  <name>ai_pilot</name> <!-- for AI aircraft -->
<visible_in_range>
  <parameter>
  <code> (A:LIGHT BEACON, bool) (A:VELOCITY BODY Z, knots) 0 != || </code>
  </parameter>
  <minvalue>1</minvalue>
  <maxvalue>2</maxvalue>
  </visible_in_range>
  </part>
Does the job. I assume body velocity works because a running engine creates vibrations or perhaps a little forward creeping? I'd have thought sampling prop RPM would be better, but the crew seem to flicker momentarily when that value is sampled. I know how they feel.
Reply With Quote
  #16  
Old 15 Aug 2012, 14:09
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Quote:
Originally Posted by Here for the Beer View Post
Does the job. I assume body velocity works because a running engine creates vibrations or perhaps a little forward creeping? I'd have thought sampling prop RPM would be better, but the crew seem to flicker momentarily when that value is sampled. I know how they feel.
That variable need only be 0.0000000000000001 for it to return as "true" (1)...

...prop rpm is much less precise.
__________________
Bill Leaming
3d Modeler Max/GMax
C & XML Gauge Programmer
Eaglesoft Development Group
http://eaglesoftdg.com

Intel® Core™ i7-3770k 4.2GHz - Crucial 16GB DDR3 - Dual Radeon HD770 1GB DDR5 (Crossfire) - Eco II Watercooling - Win7 64bit
Intel® Core™ i7-2600k 3.4GHz - Crucial 4GB DDR3 - NVIDIA GeForce GTX550Ti 1GB - Win7 64bit
Intel® Core™ i7-860 2.8GHz - Crucial 8GB DDR3 - NVIDIA GeForce GTS240 1GB - Win8 64bit
NOTE: Unless explicitly stated otherwise, everything written by my hand is MY opinion. I do NOT speak for any company, real or imagined...
Reply With Quote
  #17  
Old 15 Aug 2012, 15:27
Here for the Beer Here for the Beer is offline
  unitedkingdom
Location: Wiltshire, England
Join Date: Mar 2007
Posts: 282
So the people flicker because the passenger is nervous, got it.

The bind with the prop RPM is that at least for AI, it just means the prop is stopped instantaneously - going by the value. I'd been hoping that by adding a little prop inertia in the FDE, I could have the crew there for a few moments longer and have them disappear definitively once the prop had spun down, but prop spinning and not spinning is an instantaneous binary state for the sim, more's the pity, and there's nothing more wrong-looking than an empty aircraft with a spinning prop!

Still, it works better than it did this time yesterday, so I'm grateful for that. Just a shame our car doesn't...

Last edited by Here for the Beer; 15 Aug 2012 at 16:25.
Reply With Quote
  #18  
Old 17 Aug 2012, 13:50
tgibson tgibson is offline
  us-california
Location: San Diego
Join Date: Sep 2006
Posts: 3,200
Hi,

My original code wouldn't work because of a missing equals sign. I've now added it.
__________________
Tom Gibson
CalClassic Propliners
http://www.calclassic.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FSXA] XML Code Help needed mike november Gauges 8 17 Feb 2012 18:27
[FS2004] Canopy transparency and prop0_blurred rotation John Young Modeling 10 25 Jan 2011 15:25
Help needed - FSX Gamepack GUID script problem OryxSim GMax and 3DS Max 1 25 Jul 2010 06:53
Gauge code question lionheart Gauges 1 12 Aug 2009 14:58
ILS Altitude Alan McGaughey Airport Design Editor 18 06 Aug 2008 04:49


All times are GMT -4. The time now is 11:15.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.