Yay! Thank you, André, thank you very much for your donation and support! This is what André wrote:
from Nokman for the real_time and more thx
Ok, will tell you this, I’m currently working on yet another extension, pretty useful one too… But enough for now, back to the tutorial
So, something wonderful has happened… There have been some changes in the way arrays are handled. I’m currently waiting for official confirmation that arrays have indeed received some love from BIS programmers. In the mean time I revisited my earlier tutorials on arrays and then tested it in Arma 2 to make sure no mistake was made then. The earlier tuts are still valid for Arma 2. Dev branch of Arma 3 however has new handling, hopefully soon to be transferred to the main branch.
The changes affect in, find and - commands. In short, you can now use these commands with multidimensional arrays (arrays inside arrays). Let me demonstrate this on a few examples:
As you can see in command will now treat array in array just like another element of the base array. Base array: [element1, element2, element3...] where any element could be an additional array construct, [1,[2,,4]] for example. The same applies to find command:
But I personally think the best use of the enhanced functionality is that you can now remove elements of multidimensional arrays with more ease:
Note that in order to remove an element you have to define it from the base line: [[[]]] in the above example, not 4, , [] or [[]]. And since this post is rather short, I’m going to top it up by sharing my version of arrayShuffle function (See EDIT2 at the bottom for the faster version):
KK_fnc_arrayShuffle is almost 4 times faster than BIS_fnc_arrayShuffle when compared on just 10 elements array. Also, it actually modifies the original array, just like PHP’s shuffle(). In addition I made it also return the array to make it behave like BIS function. Usage:
And why not to make it even better by adding another param to the function to have control over the strength of shuffling? Because of how KK_fnc_arrayShuffle works, it is quite easy to expand its functionality: (See EDIT2 at the bottom for the faster version)
The the number of default shuffling iterations is equal to the length of array, this is how it is in BIS function. With KK_fnc_arrayShufflePlus you can make a stronger or weaker shuffle if you want by passing second argument with desired number of iterations. Usage:
EDIT: KK_fnc_arrayShuffle updated, thanks to Master85 for pointing out hidden flaw. Fixed. Also here is even faster function based on Fisher-Yates algorithm:
EDIT2: Thought I’d revisit the shuffle function because of the new commands added to Arma 3, mainly pushBack and deleteAt. After testing new algorithm based on these new commands, I can tell you that it is 2.5 times faster than Fisher-Yates algorithm. Therefore I’m going to rewrite both shuffle functions, normal and plus, but will leave the old ones as an example of how not to code .