I am failing with loops/ascents to perform the following case:
- Assume I have a stage with 5, 13 and 24 spell cards
> For example for the one with 13 cards, I wish to put the first cards 10 into a 2D array
> Then I wish to put the remaining 3 into the same array, but next element position
So the desired result in my mind is this:
array = [
[card1, card2, ..., card10],
[card11, card12, card13]
];
However, when there are less than 10 cards. I just wish to perform this loop once so the array contains only one element. Also, If there are 24 cards. Then I need to cycle 2x filling up 10 cards but each inner array may only contain 10 cards.
I know how to concatenate into 2D arrays thanks to Drake, though I fail to put it all together into a loop/ascent. I am guessing I need a loop inside a loop.
Finally, the reason for this all is my wish to implement it for my Spell Practice screen. So I can jump a 'pageNumber' to cycle through the elements in the 2D array and using 'cardNumber' I can cycle through the cards in the highlighted element. Basically a revolving/wrapping list of spell cards.
Here is something I tried but got stuck. Note: This code doesn't work.
let cardsInPageArray = [];
totalPages = 0;
let index = 1;
let temporaryArray = [];
ascent(i in 0..totalPages) {
ascent(j in 0..numberOfCards) {
let setText = "Spell Card " ~ IntToString(index);
let textObject = writeGraphicalText(160, 100 + (j*22), 255, 17, [255,255,255], [255,255,255], [42,99,122], 512, setText);
temporaryArray = temporaryArray ~ [textObject];
index++;
}
cardsInPageArray = cardsInPageArray ~ [temporaryArray];
}
writeGraphicalText is a function that spawns a Text Object. Later on using the arrow keys, the highlighted text object will lit up (animation for selecting cards)