• 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!

GameMaker Script with Unlimited Arguments?

Fixer90

Member
I am mostly aware of how GML's script system works — with arguments and whatnot. However, I am curious as to if there is a way to make a script with no limit to arguments, similar to some built-in functions in GML (ex. ds_list_add). Is this possible?
 
H

Homunculus

Guest
Scripts are, as far as i know, limited to 16 arguments. edit: as pointed out, this limit has been removed when using the argument[] array.

Something like
Code:
foo([2, 8, 13, 1])
is also valid and has no fixed limit.

I’m assuming the question is about the maximum number of argument, and not simply about scripts having a variable number of arguments
 
Last edited by a moderator:

Simon Gust

Member
There are your basic argument0 to argument15.
But there is also just "argument" as an array.
The keyword argument_count will then tell you, how many arguments you have provided.
 
H

Homunculus

Guest
I guess I missed another update info somewhere, thanks for correcting me @YellowAfterlife . The limit has been removed in version 1.4.1760.
 

zATARA_0

Member
if you dont know how many arguments you want you can also add some code like this.
var setArgs = 3;
for (var i = setArgs; i < argument_count; ++ i){
if (argument_count > i){
var thing = argument;
}
}
 
Top