GMS 2.3+ Is the argument array still necessary in 2.3?

samspade

Member
While you don't need to use the argument array if you want to pass in less than the max amount of arguments, as GM will provide undefined for those, I can't see away to get around it for an issue like this where you want to pass in an unspecified number of arguments (short of turning those arguments into your own array and passing them in as one argument).

GML:
function array_add_to_end() {
    var _array = argument[0];   
    for (var i = 1; i < argument_count; i += 1) {
        _array[@ array_length(_array)] = argument[i];
    }   
    return _array;
}
Am I missing a way to do it, or is the augment array still necessary in this case?
 
While you don't need to use the argument array if you want to pass in less than the max amount of arguments, as GM will provide undefined for those, I can't see away to get around it for an issue like this where you want to pass in an unspecified number of arguments (short of turning those arguments into your own array and passing them in as one argument).

GML:
function array_add_to_end() {
    var _array = argument[0]; 
    for (var i = 1; i < argument_count; i += 1) {
        _array[@ array_length(_array)] = argument[i];
    } 
    return _array;
}
Am I missing a way to do it, or is the augment array still necessary in this case?
As @FrostyCat said this is still the only way to do stuff like accessing a random number of parameters. For your use-case in specific, v2.3.1 beta now has functions to push elements to the end of the array.

array_push(array, val1, val2, val3, ....)
 
Last edited:
Top