il88pp Posted June 21, 2020 Share Posted June 21, 2020 (edited) Hi all. Hope you're well. A little question. I'm working on a gauge but iot is not finished yet. It is an "invisible gauge" that listens for A:variables and does things according to what those A:variables are. That means it is a gauge with only elements like so: And I am now wondering if I can combine all those elements into one. (As the gauge is not finished yet I can't simply try and see the result..) Below is just a small example of what I mean. It's not the actual gauge. Only parts of it and with A: and L:Vars completely chosen random for this example only. --- This is generally what the gauge elements look like now: ------- (L:INIT) 0 == if { 0 (>L:12345) 0 (>L:32A56) } (A:bbbbbb) && if { 1 (>L:12345) } els { 0 (>L:12345) } (L:INIT) 0 == if { 0 (>L:12345) 0 (>L:32A56) } --- I would like to combine them as :-----(same code, just fewer tags) ------- (L:INIT) 0 == if { 0 (>L:12345) } (A:bbbbbb) && if { 1 (>L:12345) } els { 0 (>L:12345) } (L:12345) if { 1 (>K:ABCDE) 0 (>L:INIT) } -------------------------------------------------------------------------- I my gauge there are more elements, but all elements are like the ones above. So: CODE and all have the same type of Code in them: (A:var) or (L:var) value == if { do one thing } els { do some other thing } many only have an if { **** } option and no els { #### } part. Thanks for reading, hope you know the answer.:D Thanks in advance. il. Edited June 21, 2020 by il88pp [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
andiroto Posted June 22, 2020 Share Posted June 22, 2020 Hello, Yes you can merge it into one element but without spaces between "if" or "els": (A:AAA,percent) 10 > if{ 1 (>L:CCC,number) } els{ 2 (>L:CCC,number) } (L:DDD,number) 1 == (L:EEE,number) 1 == AND if{ 3 (>L:FFF,number) } els{ 4 (>L:FFF,number) } There are restrictions on the maximum of lines in an element, but I don't know the number or size! Link to comment Share on other sites More sharing options...
il88pp Posted June 22, 2020 Author Share Posted June 22, 2020 Thanks!! Just to make sure, when you say "no space between "if" and "els"" I assume you mean: nospace between if and { yes? (and between els and { of course) so you meant: if{ instead of: if { Yes? Also, is it be OK to keep my hard returns in there or do they also need to go? For example, is the following OK: (A:AAA,percent) 10 > if{ 1 (>L:CCC,number) } els{ 2 (>L:CCC,number) } (L:DDD,number) 1 == (L:EEE,number) 1 == AND if{ 3 (>L:FFF,number) } els{ 4 (>L:FFF,number) } Or does it have to be like you posted: (A:AAA,percent) 10 > if{ 1 (>L:CCC,number) } els{ 2 (>L:CCC,number) } (L:DDD,number) 1 == (L:EEE,number) 1 == AND if{ 3 (>L:FFF,number) } els{ 4 (>L:FFF,number) } [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
andiroto Posted June 22, 2020 Share Posted June 22, 2020 Yes, right! No space between "if,els" and "{"! I personally try to have as few paragraphs as possible in a block of code but your partitions should also work! Link to comment Share on other sites More sharing options...
il88pp Posted June 22, 2020 Author Share Posted June 22, 2020 Thank you very much for the (quick) reply! I like keeping things in their own lines to keep the overview while creating and editing. Thanks again:D, il. [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
n4gix Posted June 25, 2020 Share Posted June 25, 2020 (edited) A few comments regarding your scheme. I would suggest using an ... instead of the scheme you have. It's less verbose and uses the section as it was intended to be used. Also, AND in XML is all lower-case "and" or && Here is an example of what I use as a "C310R Logic.xml" where I initialize many, many variables in a Do Once loop, and keep other variables updated on ever sim cycle (18 Hz): [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font] [/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][font=Consolas][size=2] (L:DoOnce,bool) ! if{ [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/size][/font][/size][/font] [/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] (L:C310_ColdDark, bool) (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) and if{ 1 (>K:PARKING_BRAKES,bool) 1 (>L:C310_Pilot,bool) 1 (>L:C310_Chocks,bool) 1 (>L:C310_Covers,bool) 0 (>L:SwitchLL,enum) (A:LIGHT TAXI,bool) if{ (>K:TOGGLE_TAXI_LIGHTS) } 0 (>L:LeftMag_Left, number) 0 (>L:LeftMag_Right, number) 0 (>L:RightMag_Left, number) 0 (>L:RightMag_Right, number) 0 (>K:MIXTURE1_SET) 0 (>K:MIXTURE2_SET) 0 (>K:COWLFLAP1_SET) 0 (>K:COWLFLAP2_SET) (>K:PANEL_LIGHTS_OFF) 0 (>L:SwitchEngLts, enum) 0 (>L:SwitchRadioLts, enum) 0 (>L:SwitchFLTLts, enum) 0 (>L:SwitchPNLLts, enum) (A:LIGHT BEACON,bool) if{ (>K:TOGGLE_BEACON_LIGHTS) } (A:LIGHT STROBE,bool) if{ (>K:STROBES_TOGGLE) } (A:LIGHT NAV,bool) if{ (>K:TOGGLE_NAV_LIGHTS) } (A:AVIONICS MASTER SWITCH,bool) if{ (>K:TOGGLE_AVIONICS_MASTER) } (A:ELECTRICAL MASTER BATTERY,bool) if{ (>K:TOGGLE_MASTER_BATTERY) } (A:GENERAL ENG MASTER ALTERNATOR:1,bool) if{ (>K:TOGGLE_ALTERNATOR1) } (A:GENERAL ENG MASTER ALTERNATOR:2,bool) if{ (>K:TOGGLE_ALTERNATOR2) } 0 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_SET)[/size][/font][/size][/font] [/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 0 (>L:FuelSelectLeft, enum) 0 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_2_SET)[/size][/font][/size][/font] [/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 0 (>L:FuelSelectRight, enum) (>K:ENGINE_AUTO_SHUTDOWN) 1 (>L:FirstLoad,bool) } [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [font=Consolas][size=2][font=Consolas][size=2] (L:C310_ColdDark, bool) ! (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) ! or if{ 16384 (>K:MIXTURE1_SET) 16384 (>K:MIXTURE2_SET) 1 (>L:LeftMag_Left, number) 1 (>L:LeftMag_Right, number) 1 (>L:RightMag_Left, number) 1 (>L:RightMag_Right, number) (>K:TOGGLE_STARTER1) (>K:TOGGLE_STARTER2) 0 (>L:C310_Pilot,bool) 0 (>L:C310_Chocks,bool) 0 (>L:C310_Covers,bool) 0 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_SET)[/size][/font][/size][/font] [/size][/font][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 2 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_SET)[/size][/font][/size][/font] [/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 1 (>L:FuelSelectLeft, enum) 0 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_2_SET) [font=Consolas][size=2][font=Consolas][size=2] 3 ([font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]K:FUEL_SELECTOR_2_SET)[/size][/font][/size][/font][/size][/font][/size][/font][/size][/font][/size][/font] [/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 1 (>L:FuelSelectRight, enum) (A:CIRCUIT AVIONICS ON,bool) if{ 0 (>L:Avionics_On_Init,enum) } (A:ANTISKID BRAKES ACTIVE,bool) 0 == if{ (>K:ANTISKID_BRAKES_TOGGLE) } (A:LIGHT LANDING,bool) if{ 2 (>L:SwitchLL,enum) } (>K:PANEL_LIGHTS_OFF) (A:LIGHT BEACON,bool) ! if{ (>K:TOGGLE_BEACON_LIGHTS) } (A:LIGHT STROBE,bool) ! if{ (>K:STROBES_TOGGLE) } (A:LIGHT NAV,bool) ! if{ (>K:TOGGLE_NAV_LIGHTS) } 16383 (>K:COWLFLAP1_SET) 16383 (>K:COWLFLAP2_SET) (A:ELECTRICAL MASTER BATTERY,bool) ! if{ (>K:TOGGLE_MASTER_BATTERY) } (A:GENERAL ENG MASTER ALTERNATOR:1,bool) ! if{ (>K:TOGGLE_ALTERNATOR1) } (A:GENERAL ENG MASTER ALTERNATOR:2,bool) ! if{ (>K:TOGGLE_ALTERNATOR2) } (A:AVIONICS MASTER SWITCH,bool) ! if{ (>K:TOGGLE_AVIONICS_MASTER) } (>K:ENGINE_AUTO_START) 1 (>L:FirstLoad,bool) } 1 (>L:DoOnce,bool) } (A:GENERAL ENG PROPELLER LEVER POSITION:1,percent) 0 > (L:Prop1_Feathered,bool) and if{ 0 >L:Prop1_Feathered,bool) } (A:GENERAL ENG PROPELLER LEVER POSITION:2,percent) 0 > (L:Prop2_Feathered,bool) and if{ 0 >L:Prop2_Feathered,bool) } (L:LeftMag_Left, number) ! (L:LeftMag_Right, number) ! and if{ (>K:MAGNETO1_OFF) } (L:LeftMag_Left, number) (L:LeftMag_Right, number) ! and if{ (>K:MAGNETO1_LEFT) } (L:LeftMag_Left, number) ! (L:LeftMag_Right, number) and if{ (>K:MAGNETO1_RIGHT) } (A:RECIP ENG LEFT MAGNETO:1,bool) ! (L:LeftMag_Left, number) (L:LeftMag_Right, number) and and if{ (>K:MAGNETO1_BOTH) } (L:RightMag_Left, number) ! (L:RightMag_Right, number) ! and if{ (>K:MAGNETO2_OFF) } (L:RightMag_Left, number) (L:RightMag_Right, number) ! and if{ (>K:MAGNETO2_LEFT) } (L:RightMag_Left, number) ! (L:RightMag_Right, number) and if{ (>K:MAGNETO2_RIGHT) } (A:RECIP ENG RIGHT MAGNETO:2,bool) ! (L:RightMag_Left, number) (L:RightMag_Right, number) and and if{ (>K:MAGNETO2_BOTH) } (A:ELECTRICAL MASTER BATTERY,bool) if{ (L:MB_On_Init,enum) 0 == if{ 1 (>L:XMLSND10,bool) 1 (>L:MB_On_Init,enum) } (L:MB_On_Init,enum) 1 == if{ 2 (>L:XMLSND11,bool) } } (A:ELECTRICAL MASTER BATTERY,bool) ! (L:MB_On_Init,enum) 1 == and if{ 3 (>L:XMLSND11,bool) 1 (>L:XMLSND12,bool) 0 (>L:MB_On_Init,enum) } (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 > (A:ELECTRICAL MASTER BATTERY,bool) and if{ (L:Avionics_On_Init,enum) 0 == if{ 1 (>L:XMLSND13,bool) 1 (>L:Avionics_On_Init,enum) } (L:Avionics_On_Init,enum) 1 == if{ 2 (>L:XMLSND14,bool) } } (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 == (A:ELECTRICAL MASTER BATTERY,bool) ! or (L:Avionics_On_Init,enum) 1 == and if{ 3 (>L:XMLSND14,bool) 1 (>L:XMLSND15,bool) 0 (>L:Avionics_On_Init,enum) } (L:Primer,enum) 0 != (A:ELECTRICAL MASTER BATTERY,bool) and if{ 2 (>L:XMLSND16,bool) } els{ 3 (>L:XMLSND16,bool) } (A:ELECTRICAL MASTER BATTERY,bool) (L:DoorSeal, number) 0 == and if{ (P:Absolute time,seconds) 30 % 1 > ! if{ 1 (>L:XMLSND18,bool) } } (A:EXIT OPEN:0,percent) 0 [font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] (L:CabinLtsOvd, enum) 0 == and if{ 1 (>L:SwitchCabinLts, enum) }[/size][/font][/size][/font][/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] (A:EXIT OPEN:0,percent) 0 == (L:CabinLtsOvd, enum) 0 == and if{ 0 (>L:SwitchCabinLts, enum) } [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [font=Consolas][size=2][font=Consolas][size=2] (A:BRAKE PARKING POSITION,percent) 0 [font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][/size][/font][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000] [/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] (L:C310_Chocks,bool) 1 == or if{ 1 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 1 (>K:FREEZE_ATTITUDE_SET) } els{ 0 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 0 (>K:FREEZE_ATTITUDE_SET) } (L:SND_INVC,bool) ! (L:SND_MUTE,bool) or (L:SND_PAUSE,bool) or if{ 1 (>L:SND_GLOBALMUTE,bool) } els{ 0 (>L:SND_GLOBALMUTE,bool) } (A:ELECTRICAL MAIN BUS VOLTAGE, volts) 5 [font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000][font=Consolas][size=2][color=#ff0000]>[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] sp0[/size][/font][/size][/font][/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2] (L:SwitchFLTLts,enum) l0 * (>L:SwitchFLTLtsON,enum) (L:SwitchPNLLts,enum) l0 * (>L:SwitchPNLLtsON,enum) (L:SwitchEngLts,enum) l0 * (>L:SwitchEngLtsON,enum) (L:SwitchRadioLts,bool) l0 * (>L:SwitchRadioLtsON,bool) (L:SwitchRadioLtsON,bool) if{ (>K:PANEL_LIGHTS_ON) } els{ (>K:PANEL_LIGHTS_OFF) } [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff] [font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]Update[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]>[/color][/size][/font][/color][/size][/font][/color][/size][/font] [/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]Gauge[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]>[/color][/size][/font][/color][/size][/font][/color][/size][/font] [/color][/size][/font][/color][/size][/font][/color][/size][/font] Edited June 25, 2020 by n4gix Bill Leaming http://smileys.sur-la-toile.com/repository/Combat/0054.gif Gauge Programming - 3d Modeling Military Visualizations Flightsim.com Panels & Gauges Forum Moderator Flightsim Rig: Intel Core i7-2600K - 8GB DDR3 1333 - EVGA GTX770 4GB - Win7 64bit Home Premium Development Rig1: Intel Core i7-3770k - 16GB DDR3 - Dual Radeon HD7770 SLI 1GB - Win7 64bit Professional Development Rig2: Intel Core i7-860 - 8GB DDR3 Corsair - GeForce GTS240 1GB - Win7 64bit Home Premium NOTE: Unless explicitly stated in the post, everything written by my hand is MY opinion. I do NOT speak for any company, real or imagined... Link to comment Share on other sites More sharing options...
il88pp Posted June 29, 2020 Author Share Posted June 29, 2020 Hi n4gix, thanks for that. I haven't looked at it closely yet. I feel a bit overwhelmed at the moment by the changes in the covid situation. Another reason I haven't looked at it closely is that I have a bum shoulder at the moment so sitting at the pc is out and what you posted was a bit long to pick apart on my phone. The gauge I was making (invisible gauge that plays sound when you switch AP on or off) did not work and played both sounds over and over. I did find a thread over do FSDeveloper where someone had the exact same issue with both sounds playing over and over. You posted in that thread a very elegant looking solution. I bookmarked that, and when my shoulder is up and running again I'll look at that solution first. If I get it working I'll get back to this and try to get my original solution working as well. (I want to find the fault in my original logic. :) ) I did manage to make a Visible lightswitch with clickspot that plays a sound when clicked. That one I did get working. (my first ever attempt at making a sound gauge.) [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Recommended Posts