Jump to content
Sign in to follow this  
n4gix

XML Animation Code

Recommended Posts

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


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest FelixFFDS

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!

Share this post


Link to post
Share on other sites
Guest tallafourcharlie

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...