Jump to content
Sign in to follow this  
OneDownOne2Go

Triggering events from select-statements in XML

Recommended Posts

Hi,once more, it's me with a neewbe-question. Sorry for that...With all the kind help, programming goes along quite well. Now I found a new problem I cannot solve and find no hints on:I want to trigger an event depending on conditions checked by a select-statement. The idea is to create a virtual "co-pilot" that will do certain things he would do in real life. Like operating the gear, flaps, spoilers, airbrake, thrust-reverses etc. based on simulator-conditions and a preselectedt mode like taxi, takeoff, climb, cruise, descent, approch, land etc...Looks like this:(A:AIRSPEED INDICATED, knots) (L:VCP_FLU1_SPEED, knots) ><-trigger event here->I Also tried:(A:AIRSPEED INDICATED, knots) (L:VCP_CONTROL_SPEED, knots) >(>K:FLAPS_UP)as a basic test. I Know this will fire the trigger over and over again as long as condition is true. But it just did nothing.. What do I have to do to fire a trigger here?

Share this post


Link to post
Share on other sites

Hi,Try something like:(A:AIRSPEED INDICATED, knots) (L:VCP_FLU1_SPEED, knots) >if{ (A:FLAPS HANDLE INDEX,enum) 0 > if{ (>K:FLAPS_UP) }or something els you want. } els{ here something different. }Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

What you try to do (triggering events in a Case construction) simply isn't defined in XML.The usage of the Case construction (unlike in "normal" programming languages) is very limited in XML.As far as I know, the Case can only be used for two things:1. Selection of an Image (the construction you mentioned)2. Selection of a value (numerical or string) from a list, based on the value of an enumerated variable.Like in:10 20 30 3 (G:Var1) casethat pushes the value 10 , 20 or 30 onto the stack if (G:Var1) is resp. 2,1, or 0.Or in:'string1' 'string2' 2 (G:Var1) caseBut, as Jan said, what you are trying to accomplish can simply be done with (nested) if-els constructions.Rob Barendregt

Share this post


Link to post
Share on other sites

Just to add one thing Rob forgot to mention (I learned a lot from him, so I guess this is nothing new to him...)To trigger an event only once use a spcific variable for this, which by default has a zero value. But after the triggering set this variable to something different like this:(L:test,bool) 0 == if{ -trigger event- 1 (>L:test,bool) }So the -trigger event- will only be executed once.Simple, isn't it?Herbert

Share this post


Link to post
Share on other sites

>Just to add one thing Rob forgot to mention (I learned a lot>from him, so I guess this is nothing new to him...)>>To trigger an event only once use a spcific variable for this,>which by default has a zero value. But after the triggering>set this variable to something different like this:>>(L:test,bool) 0 == if{ -trigger event- 1 (>L:test,bool) }>>So the -trigger event- will only be executed once.>>Simple, isn't it?>>>>Herbert>Hi,The other way could be useful as well: (My Condition to fire the event) (>L:test,bool)......(L:test,bool) if{ -trigger event- 0 (>L:test,bool) }since then one can have control of the moment the event needs to be fired. If the trigger is (L:test,bool) 0 ==, as soon as the gauge initializes the event will be fired automatically, which may not be desirable in many circumstances.Tom

Share this post


Link to post
Share on other sites

Hi,Question:Something like what I use:(L:vnav switch,enum) 1 == if{ (L:vnav pitch,bool) ! if{ (>K:SYNC_FLIGHT_DIRECTOR_PITCH) 1 (>L:vnav pitch,bool) } } els{ (L:vnav pitch,bool) if{ (>K:SYNC_FLIGHT_DIRECTOR_PITCH) 0 (>L:vnav pitch,bool) } } Afaik there is no A:Var for the K:Event??Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Thx alot for all the help.My virtual co-pilot works well by now.. just in time to find that others had the same idea and solved that already. Well, at least I learned something.

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