ACE3 icon indicating copy to clipboard operation
ACE3 copied to clipboard

Array in QUOTE() bug

Open havena opened this issue 11 years ago • 4 comments

hi,

if i use "in [x,y]" in "condition = QUOTE(....);" action condition are always true.

ex :

class ACE_actiontest {
                    displayName = "test";
                    distance = 4;
                    condition = QUOTE((_target isKindOf 'Man') && {!alive _target} && {playerSide in [west,independent]} && {'Medikit' in (items _player)});
                    statement = QUOTE([_target] spawn xxxx);
                    exceptions[] = {"isNotSwimming"};
                    showDisabled = 0;
                    priority = 2.5;
                    hotkey = "R";
                  };

this action is always available.

class ACE_actiontest {
                    displayName = "test";
                    distance = 4;
                    condition = "(_target isKindOf 'Man') && {!alive _target} && {playerSide in [west,independent]} && {'Medikit' in (items _player)}";
                    statement = QUOTE([_target] spawn fnc_test);
                    exceptions[] = {"isNotSwimming"};
                    showDisabled = 0;
                    priority = 2.5;
                    hotkey = "R";
                  };

this work nice

havena avatar May 17 '15 21:05 havena

The QUOTE macro has multiple limitations. It has trouble with multiple embedded statements and especially arrays. It is mainly used so we can expand macros inside of strings .You cannot do "FUNC(asdf)") for example - this is a scenario where QUOTE is needed.

Your case, it is failing to complete the macro due to the array

jaynus avatar May 17 '15 21:05 jaynus

thx for info

havena avatar May 17 '15 21:05 havena

QUOTE((_target isKindOf 'Man') && {!alive _target} && {playerSide in [ARR_2(west,independent)]} && {'Medikit' in (items _player)});

Note the ARR_2

It's not easy writing complex, QUOTEable code, so an easy and clean method would be to put all your conditionals into a function and just call it.

e.g.:

condition = QUOTE(_this call canCheckFnc);

canCheckFnc = {
_target = _this select 0;
_player = _this select 1;
(_target isKindOf 'Man') && {!alive _target} && {playerSide in [west,independent]} && {'Medikit' in (items _player)}
};

PabstMirror avatar May 17 '15 21:05 PabstMirror

@havena, this is the correct syntax for your action:

class ACE_actiontest {
    displayName = "test";
    distance = 4;
    condition = QUOTE((_target isKindOf 'Man') && {!alive _target} && {playerSide in [ARR_2(west,independent)]} && {'Medikit' in (items _player)});
    statement = QUOTE([_target] spawn fnc_test);
    exceptions[] = {"isNotSwimming"};
    showDisabled = 0;
    priority = 2.5;
    hotkey = "R";
};

the ARR_X macros are your friends if you need commas inside a cba macro like QUOTE

nicolasbadano avatar May 17 '15 21:05 nicolasbadano