Board index FlightGear Development

Checklists: How to use multiple conditions

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Checklists: How to use multiple conditions

Postby mhab » Sat Nov 16, 2013 5:48 pm

Hello

I would like to use more than one condition for a single checklist item.
It seems to be possible, but with an undesired side effect.

If all conditions are false --> output Yellow as described, OK
if all conditions are true --> output Green as decribed, OK

BUT:

If only some conditions are true, and some are false: --> NO display at all :cry:

This seems to me to be a limitation/bug in current checklist implementation ?

Thanks
Mike-DE
mhab
 
Posts: 410
Joined: Thu Apr 18, 2013 10:59 pm
Callsign: D-MIKE
Version: 2019.1.1
OS: Win10

Re: Checklists: How to use multiple conditions

Postby Gijs » Sat Nov 16, 2013 5:53 pm

How are you adding multiple conditions? As separate <condition> blocks? I think you'll have to use or/and in a single condition block, as explained at http://wiki.flightgear.org/Howto:Animat ... Conditions
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9384
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Checklists: How to use multiple conditions

Postby mhab » Sat Nov 16, 2013 6:20 pm

Thanks for the hint.

I had done it in both ways. It doesn't seem to work properly in either.

Mike-DE
mhab
 
Posts: 410
Joined: Thu Apr 18, 2013 10:59 pm
Callsign: D-MIKE
Version: 2019.1.1
OS: Win10

Re: Checklists: How to use multiple conditions

Postby Hooray » Sat Nov 16, 2013 6:36 pm

Had trouble finding the code for this, we have a checklist.nas file in $FG_ROOT/Nasal but that's just a shim layer that integrates checklists with the tutorial system, the real code is in $FG_ROOT/gui/dialogs/checklist.xml

https://gitorious.org/fg/fgdata/source/ ... t.xml#L120
Code: Select all
# If there's a complete node, it contains a condition
                                    # that can be checked to ensure the checklist item is
                                    # complete. We display this item in yellow while the
                                    # condition is not met, and green once it is complete.
                                   
                                    var condition = item.getNode("condition");
                                   
                                    if (condition != nil) {
                                        var vis = t.getNode("visible", 1);
                                        props.copy(condition, vis);
                                        var c = t.getNode("color", 1);
                                        c.getNode("red", 1).setValue(0.2);
                                        c.getNode("green", 1).setValue(1.0);
                                        c.getNode("blue", 1).setValue(0.2);


Based on looking very briefly at the code, I think it was indeed never written with support for multiple conditions in mind, which I also find kinda surprising, because all the SGCondition stuff is actually handled by a props.nas wrapper. Note I really only looked at it for a second, and I was specifically looking for some form of foreach loop, so there's something else/smarter happening somewhere, I may have missed it completely, and may thus be also completely wrong here - will have another look tomorrow...

Anyways, it should be trivial to support this, no matter what the current state is.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11375
Joined: Tue Mar 25, 2008 8:40 am

Re: Checklists: How to use multiple conditions

Postby Philosopher » Sun Nov 17, 2013 2:47 am

Just use a single condition with Boolean logic, fully supported (see like three different places for this: the code in props.nas, the README, and the wiki article (I think that duplicates the README though...)).

EDIT: Yeah, what Gijs lined to ;). Keep in mind that a <condition> tag acts like a <and> tag too, so just write multiple conditions in there. In general, one shouldn't need multiple condition tags, since it's already taken care of.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5


Return to Development

Who is online

Users browsing this forum: Applebot [Bot] and 1 guest