Comment 3 for bug 672195

Revision history for this message
ron&bram (ronaldestherbram) wrote :

It is true that the action condition that the lights of loc must be on or off does not exists. I did some work on the code in action.c and came up with the code below. I tested it with all possible combinations of fon/foff and functions f0 and f1 and it all worked.

Commit?

                  if( fonoff != NULL && fnumber != NULL ) {
                    int nr = atoi(fnumber);
                    int fx = wLoc.getfx(LocOp.base.properties(lc));
                    Boolean lights = wLoc.isfn(LocOp.base.properties(lc));
                    rc = False;
                    if( StrOp.equals( "fon", fonoff ) && nr == 0 )
                      rc = lights;
                    else if( StrOp.equals( "foff", fonoff ) && nr == 0 )
                      rc = !lights;
                    else if( StrOp.equals( "fon", fonoff ) && nr != 0 )
                      rc = ( fx & (1 << (nr-1)) );
                    else if( StrOp.equals( "foff", fonoff ) && nr != 0 )
                      rc = ( !(fx & (1 << (nr-1)) ) );