Pixel-Composer/scripts/array_functions/array_functions.gml
2022-09-27 11:37:28 +07:00

24 lines
No EOL
511 B
Text

function array_safe_get(arr, index, def = 0) {
if(index >= array_length(arr)) return def;
return arr[index];
}
function array_exists(arr, val) {
for( var i = 0; i < array_length(arr); i++ ) {
if(arr[i] == val) return true;
}
return false;
}
function array_find(arr, val) {
for( var i = 0; i < array_length(arr); i++ ) {
if(arr[i] == val) return i;
}
return -1;
}
function array_remove(arr, val) {
if(!array_exists(arr, val)) return;
var ind = array_find(arr, val);
array_delete(arr, ind, 1);
}