Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XML Animation Code

Featured Replies

  • Moderator

Never mind... I found my problem... Stupid syntax error!

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author
  • Moderator

Just for the record, the problem was this: (L:L:Wiper,enum)... :-bang *:-* But, just to be fair to myself, it was buried in a complex, nested "ladder logic" click sequence... ;)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

>Just for the record, the problem was this:> (L:L:Wiper,enum)... True, (L:L:Wiper,enum) won't work, as (L:Wiper,enum ) won't either.BUT, (L:Wiper, enum) or ( L:Wiper,enum) or ( L:Wiper, enum) will.Amazing XML by the FS team... Tom

  • Author
  • Moderator

No kidding...Anyway, here is the amazingly simple, yet highly versatile bit of "ladder logic" for a multi-position lever or rotary knob: HandWiper SwitchLeftSingle+RightSingle (M:Event) 'LeftSingle' scmp 0 == if{ (L:Wiper, enum) 3 == if{ 2 (>L:Wiper,enum) } els{ (L:Wiper, enum) 2 == if{ 1 (>L:Wiper,enum) } els{ (L:Wiper, enum) 1 == if{ 0 (>L:Wiper,enum) } } } } (M:Event) 'RightSingle' scmp 0 == if{ (L:Wiper, enum) 0 == if{ 1 (>L:Wiper,enum) } els{ (L:Wiper, enum) 1 == if{ 2 (>L:Wiper,enum) } els{ (L:Wiper, enum) 2 == if{ 3 (>L:Wiper,enum) } } } }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Bill,As as humble suggestion, why don't you use a "case" operator to simplify the code and get rid of all those "if{" structures?Man, I hate nested "if{"s (though that is MY problem and not anyone's else :-) )TomEDIT: Deep looking through your code, it seems could be even more simple: (VarValue) ++ 3 min (>VarValue) for up and (Varvalue) -- 0 max (>VarValue) for down...

  • Author
  • Moderator

>Bill,>>As as humble suggestion, why don't you use a "case" operator>to simplify the code and get rid of all those "if{">structures?>>Man, I hate nested "if{"s (though that is MY problem and not>anyone's else :-) )Simply because "case" is horribly complex in MakeMDL.parts.xml code. The two "versions" of XML are similar, but not exactly the same... ;)Here is an example of "case" used for a fuel control knob: switch_fuel_selector_LBR2 0 1 1 4 (A:FUEL TANK SELECTOR:1, enum) case 25 * 100HandHELPID_GAUGE_FUEL_SELECTORTOOLTIPTEXT_FUEL_SELECTORLeftSingle+LeftDrag+Wheel(M:Event) 'LeftSingle' scmp 0 == if{ (M:X) (>G:Var1) 2 0 1 1 4 (A:FUEL TANK SELECTOR:1, enum) case (>G:Var2) } els{ (M:X) (G:Var1) - 40 / int (G:Var2) + 0 max 2 min s0 2 0 1 1 4 (A:FUEL TANK SELECTOR:1, enum) case != if{ l0 0 == if{ (>K:FUEL_SELECTOR_LEFT) } l0 1 == if{ (>K:FUEL_SELECTOR_ALL) } l0 2 == if{ (>K:FUEL_SELECTOR_RIGHT) } }Quite honestly, that is even more complex and difficult to understand than using my "nested if's" and a darn sight more difficult to expand if needed to incorporate more possible positions.>EDIT: Deep looking through your code, it seems could be even>more simple: (VarValue) ++ 3 min (>VarValue) for up and>(Varvalue) -- 0 max (>VarValue) for down...That might work, as min and max operators are both used in the example code... Here is the complete XML code for the modeled part in question: wiper_switch(L:Wiper, enum) 50 * 100HandWiper SwitchLeftSingle+RightSingle (M:Event) 'LeftSingle' scmp 0 == if{ (L:Wiper, enum) 3 == if{ 2 (>L:Wiper,enum) } els{ (L:Wiper, enum) 2 == if{ 1 (>L:Wiper,enum) } els{ (L:Wiper, enum) 1 == if{ 0 (>L:Wiper,enum) } } } } (M:Event) 'RightSingle' scmp 0 == if{ (L:Wiper, enum) 0 == if{ 1 (>L:Wiper,enum) } els{ (L:Wiper, enum) 1 == if{ 2 (>L:Wiper,enum) } els{ (L:Wiper, enum) 2 == if{ 3 (>L:Wiper,enum) } } } } Note that I'm taking the value returned and multiplying by 50 in order to generate animation "stops" at keyframe 0, keyframe 50, keyframe 100 and keyframe 150. The parameter controls the "speed" of the animation, so that the knob (or lever) won't "snap" to the new value, but will smoothly rotate. That is because the FS9 system will automatically increment the scaled variable's output from say, keyframe 0 to keyframe 50.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author
  • Moderator

Continuing from the above code example, it is also necessary to create conditons for the actual "wiper parts."One of the peculiar things about the XML used in model code is that, while you can have a "stand-alone" X, you cannot have a stand-alone X attribute. There also is no X attribute, nor is there a ... tag available.All that means is that if you have sequential numbers in your control variable (L:Wiper,enum), then for the code, you need to scale the output * 2, so that you can define a and pair.For example: wiper_still //0=park, 1=stopped (L:Wiper,enum)*2 02wiper_fast //2=fast (L:Wiper,enum)*2 34wiper_slow //3=slow (L:Wiper,enum)*2 56

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author
  • Moderator

>EDIT: Deep looking through your code, it seems could be even>more simple: (VarValue) ++ 3 min (>VarValue) for up and>(Varvalue) -- 0 max (>VarValue) for down...Just for the record, your suggestion works perfectly as well, proving once again there's more than one way to skin a cat... ;)Thanks! LeftSingle+RightSingle (M:Event) 'LeftSingle' scmp 0 == if{ (L:Wiper, enum) -- 0 max (>L:Wiper, enum) } (M:Event) 'RightSingle' scmp 0 == if{ (L:Wiper, enum) ++ 3 min (>L:Wiper, enum) } }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • 9 months later...

Hello Guys,I jump on this "old" topic to add a question. As far as I understand, this code allows you to left-click the knob to decrease its position, an dright-click to increase its position.How can you do to let the mouse wheel increase/decrease the knob position?Thanks,Eric

  • Author
  • Moderator

>Hello Guys,>>I jump on this "old" topic to add a question. As far as I>understand, this code allows you to left-click the knob to>decrease its position, an dright-click to increase its>position.>How can you do to let the mouse wheel increase/decrease the>knob position?Sure enough! Simply add "Wheel" to the list of controls, and WheelUp and WheelDown events:LeftSingle+RightSingle+Wheel (M:Event) 'LeftSingle' scmp 0 == if{ (L:Wiper, enum) -- 0 max (>L:Wiper, enum) } (M:Event) 'WheelDown' scmp 0 == if{ (L:Wiper, enum) -- 0 max (>L:Wiper, enum) } (M:Event) 'RightSingle' scmp 0 == if{ (L:Wiper, enum) ++ 3 min (>L:Wiper, enum) } (M:Event) 'WheelUp' scmp 0 == if{ (L:Wiper, enum) ++ 3 min (>L:Wiper, enum) } }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

I already tried this, but it didn't work, as if the 'WheelUp' and 'WheelDown' events were just ignored.I will look again deeper...Thanks,Eric

Sorry, sorry !!I had a small syntax error, now fixed, and it works perfect.Thanks for your help ;-)Eric

I had to laugh!It was a "small syntax error" that started this thread, and now another one.... (What is the saying in French - The more things change, the more they stay the same..?)Thanks for an early morning chuckle!

It's at moments like these, you just want to scream ...small syntax error :D

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.