Array – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
(Kilobyte= 1000bytes, Kibibyte = 1024bytes)
 
(17 intermediate revisions by 5 users not shown)
Line 14: Line 14:
not working, why? I've also tried "tmp = tmp - val1;" --[[User:Messiah2|MessiahUA]] 16:14, 19 September 2008 (CEST)
not working, why? I've also tried "tmp = tmp - val1;" --[[User:Messiah2|MessiahUA]] 16:14, 19 September 2008 (CEST)


-----
== Getting Object data directly from an array of Objects ==


How are arrays stored in memory? Last night, I was successfully able to create an array containing 26905 elements. (one for each land grid square on Altis)
It appeared that I could only retrieve information about an object in an array by first copying the information to a non-array variable.
<code>[] spawn
 
{
e.g. 1: <''getPosATL myArray select 0;''> returned null.
_number = 0;
 
_test = [];
e.g. 2: <''myVar = myArray select 0; getPosATL myVar;''> read without issue.
_brushes = ["Solid","Horizontal","Vertical","Grid","FDiagonal","BDiagonal","DiagGrid","Cross"];
 
for "_i" from 0 to 308 do
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 ^.^)
{
 
for "_o" from 0 to 308 do
== Max items limit ==
{
 
if (!surfaceIsWater [(_o * 100) + 50, (_i * 100) + 50]) then
Is it related to 1 dimension or all items within an array? - [[User:Ilias38rus|Ilias38rus]] ([[User talk:Ilias38rus|talk]]) 01:30, 27 June 2020 (CEST)
{
: Hi, if you have the game you can try and update the wiki page. '''Again''', this is not the place to ask such question - [https://discord.gg/arma ARMA Discord] is. - [[User:Lou Montana|Lou Montana]] ([[User talk:Lou Montana|talk]]) 17:08, 27 June 2020 (CEST)
_name = format["%1_%2",_o,_i];
::Its a thing to specify and not a personal question, chesus .. [[User:Ilias38rus|Ilias38rus]] ([[User talk:Ilias38rus|talk]]) 21:07, 30 June 2020 (CEST)
_marker = createMarker [_name, [(_o * 100) + 50, (_i * 100) + 50]];
::: If we are here, it is indeed to fill the wiki - if you want to see the information on this page, test it and add it, otherwise, wait for someone that has the information to add it to the page. I believe you do have page edit rights? - [[User:Lou Montana|Lou Montana]] ([[User talk:Lou Montana|talk]]) 18:45, 1 July 2020 (CEST)
_marker setMarkerShape "RECTANGLE";
:::: 1 who already have the info may see the mention about that its missed, its still better than just ignoring if you saw the miss. [[User:Ilias38rus|Ilias38rus]] ([[User talk:Ilias38rus|talk]]) 17:26, 2 July 2020 (CEST)
_marker setMarkerSize [50,50];
_marker setMarkerBrush (_brushes select (floor random (count _brushes)));
_marker setMarkerColor "ColorRed";
_number = _number + 1;
_test pushBack _marker;
};
};
sleep 0.01;
};
hint str _number;
player setVariable ["holy_shit", _test];
_test = nil;
};</code>
I was able to confirm that the array did actually contain my elements with:
<code>'''//ran from debug console'''
_array = (player getVariable "holy_shit");
_array spawn
{
for "_i" from 0 to ((count _this) - 1) do
{
hintSilent (_this select _i);
sleep 0.05;
};
};</code>
I thought it was strange, at first, that my game didn't crash from running out of memory, but after doing some quick math everything seems to be in order. ASCII uses 7 bits and I was saving 5-6 character strings so:<br>
7 * 6 = 42<br>
42 * 26905 = 1130010 '''bits'''<br>
1130010 / 8 = 141251 '''bytes'''<br>
141251 / 1024 = 138 '''[http://en.wikipedia.org/wiki/Kibibyte kibibytes]''' or 141251 / 1000 = 141 '''[http://en.wikipedia.org/wiki/Kilobyte kilobytes]'''<br>
- [https://community.bistudio.com/wiki/User_talk:DreadedEntity DreadedEntity]

Latest revision as of 17:26, 2 July 2020

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 ^.^)

Max items limit

Is it related to 1 dimension or all items within an array? - Ilias38rus (talk) 01:30, 27 June 2020 (CEST)

Hi, if you have the game you can try and update the wiki page. Again, this is not the place to ask such question - ARMA Discord is. - Lou Montana (talk) 17:08, 27 June 2020 (CEST)
Its a thing to specify and not a personal question, chesus .. Ilias38rus (talk) 21:07, 30 June 2020 (CEST)
If we are here, it is indeed to fill the wiki - if you want to see the information on this page, test it and add it, otherwise, wait for someone that has the information to add it to the page. I believe you do have page edit rights? - Lou Montana (talk) 18:45, 1 July 2020 (CEST)
1 who already have the info may see the mention about that its missed, its still better than just ignoring if you saw the miss. Ilias38rus (talk) 17:26, 2 July 2020 (CEST)