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 6: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: 418
Joined: Thu Apr 18, 2013 11:59 pm
Callsign: D-MIKE
Version: 2020.3.4
OS: Win10

Re: Checklists: How to use multiple conditions

Postby Gijs » Sat Nov 16, 2013 6: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: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Checklists: How to use multiple conditions

Postby mhab » Sat Nov 16, 2013 7: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: 418
Joined: Thu Apr 18, 2013 11:59 pm
Callsign: D-MIKE
Version: 2020.3.4
OS: Win10

Re: Checklists: How to use multiple conditions

Postby Hooray » Sat Nov 16, 2013 7: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Checklists: How to use multiple conditions

Postby Philosopher » Sun Nov 17, 2013 3: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.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 11 guests