#Best way to grab random values from a array without repeating any?
1 messages · Page 1 of 1 (latest)
choices = [1, 2, 3, 4, 5];
choose_unique = function() {
var _n = array_length(choices);
if (_n == 0) {
return undefined;
}
var _index = irandom(_n - 1);
var _choice = choices[_index];
array_delete(choices, _index, 1);
return _choice;
};
Not sure if you wanna remove them from the array though.
thats exactly what i needed, for some reason i forgot about array_delete xD