D
dozy
Guest
[GameMaker Studio 2 version 2.2.3.436] I have made a script that uses optional arguments and it keeps giving me an error,
The section which uses optional arguments is this:
I have checked and checked again but I cannot find any reason for this not working, or even anyone else who seems to be having a problem doing this right. I hope I am just being stupid and there is something obvious here I'm missing.
Just in case it's relevant, I'll show the code that calls the script:
The whole script itself:
And finally, just for comparison, another script of mine which I can confirm has functioning optional variables:
Four arguments are supposed to be required, and two more optional. This is really baffling me because I have made other scripts with optional arguments that work perfectly. In fact, a lot of the code in this script was copy & pasted from another of said scripts to make sure it was the same, I can see no real difference in the way it works."function 'hitbox_create' expects 4 arguments, 6 provided."
The section which uses optional arguments is this:
Code:
if (argument_count > 4) { hb.dmg_interupt = argument[4]; }
if (argument_count > 5) { hb.dmg_knockback = argument[5]; }
Just in case it's relevant, I'll show the code that calls the script:
Code:
var hx = x;
var hy = y-54;
hitbox_create(hx,hy,obj_hitbox_swing,dmg,dmg_interupt,dmg_knockback);
Code:
///@func hitbox_create(x,y,type,damage,[interupt],[knockback]);
///@desc Create a hitbox and set its values
///
///@param x
///@param y
///@param type
///@param damage
///@param [interupt]
///@param [knockback]
var hb = instance_create_layer(argument0,argument1,layer,argument2);
hb.owner = id;
hb.dmg = argument3;
if (argument_count > 4) { hb.dmg_interupt = argument[4]; }
if (argument_count > 5) { hb.dmg_knockback = argument[5]; }
Code:
///@func apply_damage(damage,[interupt],[knockback]);
///@desc Apply an amount of damage and interupt frames
///
///@param damage
///@param [interupt]
///@param [knockback]
with (other.owner) {
hp -= argument[0];
if(argument_count > 1) { alarm[11] = argument[1]; interupted = true; }
else exit;
}
if(argument_count > 2) apply_knockback(argument[2]);