2022-09-27 06:37:28 +02:00
|
|
|
function array_safe_get(arr, index, def = 0) {
|
|
|
|
if(index >= array_length(arr)) return def;
|
2022-01-13 05:24:03 +01:00
|
|
|
return arr[index];
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|