Legacy GM Set default values if arguments are left blank in script

Hi Gamemaker Community, do you know how to make scripts have default values if nothing is entered in for the arguments? Example: "script_create_amber"
Code:
///script_create_amber(x, y, direction, speed, life_time)
particle = instance_create(argument0, argument1, obj_particle_amber);
particle.direction = argument2;
particle.speed = argument3;
particle.life_time = argument4;
Now you could use this script like this:
"script_create_amber(x, y, 90, 5, 1.5);"

But how can I make it so if I used the script like this(arguments left blank), it would use default values:
"script_create_amber();"

The default values for the arguments would be:
argument0 = x;
argument1 = y;
argument2 = irandom_range(45,135);
argument3 = choose(7,8,9,10,11,12);
argument4 = choose(1.5,1.6,1.7,1.8,1.9,2);

I'm guessing I'd have to do an if statement to check if an argument was entered or left blank like so:
Code:
if (argument0 == 0) {
    argument0 = x;
}

"if (argument0 == none) {
    argument0 = x;
}"
 
... And now that I'm on my computer, just like L0v3 said. For multiple optional arguments, it'll look like this, for example:

Code:
/// some_function(option_1, option_2);

var opt_1 = 0, // Default value
    opt_2 = 1; // Also default value

if (argument_count >= 1)
{
    opt_1 = argument[0];
}

if (argument_count >= 2)
{
    opt_2 = argument[1];
}

return (opt_1 + opt_2);
 
I left the script blank, no arguments, and I get an Error for the script that says "Function script_create_amber expects 3 arguments, 0 provided"

My script's code:
Code:
if (argument_count != 0) {
    particle = instance_create(x, y, obj_fx_amber_force);
    particle.direction  = argument0;
    particle.speed  = argument1;
    particle.life_time  = argument2;
} else {
    //middle particle
    particle = instance_create(x, y, obj_fx_amber_force);
    particle.direction  = irandom_range(75,105);
    particle.speed  = choose(6,7,8,9,10,11);
    particle.life_time  = choose(1.5,1.6,1.7,1.8,1.9,2);
    //left particle
    particle = instance_create(x, y, obj_fx_amber_force);
    particle.direction  = irandom_range(108,135);
    particle.speed  = choose(6,7,8,9,10,11);
    particle.life_time  = choose(1.5,1.6,1.7,1.8,1.9,2);
    //right particle
    particle = instance_create(x, y, obj_fx_amber_force);
    particle.direction  = irandom_range(45,72);
    particle.speed  = choose(6,7,8,9,10,11);
    particle.life_time  = choose(1.5,1.6,1.7,1.8,1.9,2);
}
If the script is left blank "script_create_amber" it should run the else portion of the script.
 
As i said in my first post, if you want to use optional parameters, you have to use the argument array, not the variables, ie:

Code:
my_var = argument[0]; // This

my_var = argument0; // Not this
 
Top