if – Talk

From Bohemia Interactive Community
Revision as of 12:48, 24 July 2006 by Hardrock (talk | contribs) (→‎Comment added)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Return value

Will or can the return value of the if statements be changed in such a way, that the normal braces aren't needed anymore to catch the result?

hint if(_var==1) then {"equals 1"} else {"doesn't equal 1"}

doesn't work right now, since OFP returns an error, that you can't pass if types to the hint command. This is not much of a problem, since you can simply put braces arount the if statement.

Where removing this error would be really helpful though, are "else if" statements. Caused by the above circumstances, "else if" statements have to be written like this in OFP:

if (_var==1) then
{
    hint "condition 1";
}
else (if (_var==2 && _var2==1) then
{
    hint "condition 2";
}
else (if (_var5 > 0) then
{
    hint "condition 3";
}
else
{
    hint "no condition filled";
}));

This would look much more beautiful and would be much easier to script, if we could get rid of those braces around if statements, which could be fixed easily (or not) by changing the circumstance pointed out above. --hardrock 13:48, 24 July 2006 (CEST)