Benargee/Sandbox – User

From Bohemia Interactive Community
< User:Benargee
Revision as of 23:05, 14 December 2014 by Benargee (talk | contribs)
Jump to navigation Jump to search

Template:BenargeeSandbox

Notes

Posted on 07 Aug, 2008
ColonelSandersLite

Be careful of the parenthesis around the variable you're switching on. If you accidentally use braces instead (ex: switch {_myVar} do{...), it won't error, but will always return default.
Posted on 11 Aug, 2008
Dr_Eyeball
Using switch with strings is case-sensitive, (unlike string comparisons).
Posted on 12 Aug, 2008
General Barron
To be safe about the case sensitivity issue, use the toLower or toUpper command to force all strings to a certain case.
Posted on 06 Oct, 2009
Iva
It's possible to use Boolean value as a switch and Code as case. One thing to take special care in such case is that code must be in parentheses. Example: switch (true) do { case (_boolVar): {someCode}; case (unit1 distance unit2 > 5): {someCode}; };
Posted on November 6, 2014 - 16:33 (UTC)
Eggbeast
BEWARE:
Sometimes, and I'm unsure why, numbers are treated differently (A2OA 1.63) with quote-wraps that worked
in earlier code now not working unless quote-wraps are removed, with otherwise identical code.
_number1 = (floor random 10) switch (_number1) do { case "0": { _vehicle setobjecttexture[0,"\mymodpath\textures\num1.paa"]; }; //etc };

this one below works, and the one above stopped working with 1.63
switch (_number1) do { case 0: { _vehicle setobjecttexture[0,"\mymodpath\textures\num1.paa"]; }; //etc };
Posted on December 13, 2014 - 22:41 (UTC)
Commy2
As of Arma 3 v1.36, switch returns true (BOOL) if the condition doesn't match any case and no default block is defined.

switch (0) do {case (1): {"one"};}
-> true
Posted on December 14, 2014 - 04:18 (UTC)
DreadedEntity
Function names can be used in place of code, as shown in Example 3.