FoxyOfJungle
Kazan Games
Hello!
I've been trying to solve this for a while, but it seems to me a GMS 2 bug maybe (or not?).
I'm gonna explain:
1 - I create an array of structs;
2 - I loop through the array and try to delete all items, but it doesn't delete everything, it skips some...
See:
What happens:
Yes, I could use array = [], but that's not what I'm wanting to do.
What I want to do:
I have two arrays:
I want to delete all items from
What I tried:
However this does not work because the
Does anyone have any other solution for this purpose or would you know how to solve it?
Any help is appreciated. Thank you very much!
I've been trying to solve this for a while, but it seems to me a GMS 2 bug maybe (or not?).
I'm gonna explain:
1 - I create an array of structs;
2 - I loop through the array and try to delete all items, but it doesn't delete everything, it skips some...
See:
GML:
array[0] = {
aa : 0
}
array[1] = {
aa : 1
}
array[2] = {
aa : 2
}
array[3] = {
aa : 3
}
array[4] = {
aa : 4
}
array[5] = {
aa : 5
}
array[6] = {
aa : 6
}
array[7] = {
aa : 7
}
array[8] = {
aa : 8
}
print(array); // before
for (var i = 0; i < array_length(array); ++i) {
array_delete(array, i, 1);
}
print(array); // after
What happens:
Yes, I could use array = [], but that's not what I'm wanting to do.
What I want to do:
I have two arrays:
GML:
// array 1
array1[0] = {
aa : 0
}
array1[1] = {
aa : 1
}
array1[2] = {
aa : 2
}
array1[3] = {
aa : 3
}
array1[4] = {
aa : 4
}
array1[5] = {
aa : 5
}
// array 2
array2 = [1, 3, 4];
array1
, however, keep in array1
, the numbers (array index position) that are in array2
(1, 3, 4).I'm making a game of questions and answers (quiz), and
array2
is supposed to be a list of questions to be eliminated from the question array (array1).What I tried:
GML:
for (var i = 0; i < array_length(array1); ++i) {
for (var j = 0; j < array_length(array2); ++j) {
if (i == array2[j]) break;
array_delete(array1, i, 1);
}
}
array_delete()
function is skipping the positions...Does anyone have any other solution for this purpose or would you know how to solve it?
Any help is appreciated. Thank you very much!