Array – Talk
m (I see, change was lost - readding line break) |
m (1 kB = 1024 Bytes, 1MB = 1024 kB and so on) |
||
Line 59: | Line 59: | ||
42 * 26905 = 1130010 '''bits'''<br> | 42 * 26905 = 1130010 '''bits'''<br> | ||
1130010 / 8 = 141251 '''bytes'''<br> | 1130010 / 8 = 141251 '''bytes'''<br> | ||
141251 / | 141251 / 1024 = 138 '''kilobytes'''<br> | ||
- [https://community.bistudio.com/wiki/User_talk:DreadedEntity DreadedEntity] | - [https://community.bistudio.com/wiki/User_talk:DreadedEntity DreadedEntity] |
Revision as of 10:39, 13 December 2014
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)
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)
[] spawn
{
_number = 0;
_test = [];
_brushes = ["Solid","Horizontal","Vertical","Grid","FDiagonal","BDiagonal","DiagGrid","Cross"];
for "_i" from 0 to 308 do
{
for "_o" from 0 to 308 do
{
if (!surfaceIsWater [(_o * 100) + 50, (_i * 100) + 50]) then
{
_name = format["%1_%2",_o,_i];
_marker = createMarker [_name, [(_o * 100) + 50, (_i * 100) + 50]];
_marker setMarkerShape "RECTANGLE";
_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;
};
I was able to confirm that the array did actually contain my elements with:
//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;
};
};
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:
7 * 6 = 42
42 * 26905 = 1130010 bits
1130010 / 8 = 141251 bytes
141251 / 1024 = 138 kilobytes
- DreadedEntity