Array – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 23: Line 23:


Reason is, I'd forgotten parentheses. getPosATL is expecting an object, not an array, but the code returns no object, only after '''('''myArray select 0''')''' is processed, so use parentheses where they are needed. (thnx James ^.^)
Reason is, I'd forgotten parentheses. getPosATL is expecting an object, not an array, but the code returns no object, only after '''('''myArray select 0''')''' is processed, so use parentheses where they are needed. (thnx James ^.^)
==Question==
I have an array of arrays as such: _array = [  [''array 1''], [''array 2''] ... ]
Sometimes to reach the nested arrays, I have to use an _array [select 0 [''select 0''], [''select 1''] ...] or i get an error.
Other times I have to use  _array [[''select 0''], [''select 1''] ... ] or i get an error.
I'm pretty confused.

Revision as of 19:34, 3 May 2017

Should there be any comment here or in random about randomly selecting an array element given the rounding rules? Or am I being ridiculous?

e.g.

_myArray select ((random (count _myArray)) - 0.5)

--Mr.Peanut 21:11, 28 September 2006 (CEST)


tmp = []; val1 = [1,2,3]; val2 = [3,4,5]; tmp = tmp + [val1]; tmp = tmp + [val2]; tmp = tmp - [val1];

not working, why? I've also tried "tmp = tmp - val1;" --MessiahUA 16:14, 19 September 2008 (CEST)

Getting Object data directly from an array of Objects

It appeared that I could only retrieve information about an object in an array by first copying the information to a non-array variable.

e.g. 1: <getPosATL myArray select 0;> returned null.

e.g. 2: <myVar = myArray select 0; getPosATL myVar;> read without issue.

Reason is, I'd forgotten parentheses. getPosATL is expecting an object, not an array, but the code returns no object, only after (myArray select 0) is processed, so use parentheses where they are needed. (thnx James ^.^)