Hello,
i cannot access a specific element in a multidimensional array, all i have in return when i debug is an empty object ( ).
This is what i am doing:
1- create a series of scores formed of two elements ( a numeric a string (“1.0, 1.2, 1.6, 0.7” etc) and an integer number).
var score1 = [string,number]; for example ["1.0, 1.2, 1.6, 0.7 " , 154]
var score2 = [string,number];
var score3 = [string,number];
…and so on.
I then group those score under another array:
var scorepattern1 = [[score7],[score5],[score3]];
var scorepattern2 = [[score6],[score4],[score2]];
var scorepattern3 = [[score5],[score3],[score1]];
i create another array containing the pattern i created above:
var scorepatternlibrary = [[scorepattern1], [scorepattern2], [scorepattern3]];
and finally i pick a random pattern:
var scorepatternToUse = scorepatternlibrary[Math.floor(Math.random() * scorepatternlibrary.length)];
Now, in this example, let’s assume the randomly chosen pattern is scorepattern 3.
I want to access the score at index 2 ([score1]), and get the parameter at index 0 (the string), so "1.0,1.2,1.6, 0.7 ".
What i am doing is:
Debug.Log(patternToUse[2[0]];
Am i doing wrong?
What is the right sintax to access a specific value in an array located in another array?
Is this approach the correct one?
P.S.
I am using GameSpark CloudCode (that uses JS), but the sintax might be a bit different.
I am also new to jscript so i might be using unconventional approaches…be patient!
Thanks for your help!