if – Talk
mNo edit summary |
m (→Return value) |
||
Line 42: | Line 42: | ||
:::Sorry, I passed over you have three diferent _var variables. --[[User:Djura|Djura]] 19:29, 24 July 2006 (CEST) | :::Sorry, I passed over you have three diferent _var variables. --[[User:Djura|Djura]] 19:29, 24 July 2006 (CEST) | ||
::::Exactly. We can do fine checking one variable with switch, but as soon as we have different conditions, "else if" is needed (or "elseif", as it's sometimes written) |
Revision as of 13:20, 25 July 2006
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)
- And what about switch?
switch (_var) do { case 1: { hint "condition 1"; }; case 2: { hint "condition 2"; }; default { hint "condition 3"; }; }
- I'm not sure about semicolons, but idea should be correct. --Djura 19:29, 24 July 2006 (CEST)
- Sorry, I passed over you have three diferent _var variables. --Djura 19:29, 24 July 2006 (CEST)
- Exactly. We can do fine checking one variable with switch, but as soon as we have different conditions, "else if" is needed (or "elseif", as it's sometimes written)