• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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?
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
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