• 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 Calling an Arguement Bug?

S

Spencer S

Guest
I'm having an issue where this error message appears when I call a script called scr_player_attack1:
Code:
illegal access of argument, argument is not provided to script
 at gml_Script_scr_add_item (line 3) - gridToAddTo = argument[0];
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_add_item (line 3)
called from - gml_Object_obj_player_Step_0 (line 2) - script_execute(state);
Inside the step event of my player code, I have the following:
Code:
script_execute(state);
sprite_index = playerSprite[playerStateSprite, directionFacing];

switch (state) {
    case playerstates.run: scr_player_movement();
        break;
    case playerstates.idle: scr_player_idle();
        break;
    case playerstates.attack2: scr_player_attack2();
        break;
    case playerstates.attack3: scr_player_attack3();
        break;
    case playerstates.attack4: scr_player_attack4();
        break;
    case playerstates.attack5: scr_player_attack5();
        break;
    case playerstates.attack6: scr_player_attack6();
        break;
    case playerstates.attack1: scr_player_attack1();
        break;
}
The thing is, I never, in my entire code, call the scr_add_item which is what the error message is telling me the problem is. And scr_player_attack1 and scr_player_attack2 are both empty. The really weird thing is, when I set the variable "state" equal to playerstates.attack2, it works just fine, but setting the variable "state" to playerstates.attack1 doesn't work. AND, if I rename everything to do with "attack1" to be "attack0", it works just fine. Is there some sort of issue GML has with the number 1?
 
I

icuurd12b42

Guest
the error is saying, Hey I called script_execute... with state... state was set to the script
scr_add_item. in that script you tried to use argument[0] which was never passed.

Now possibly state is set to 0 or a value that matches the script index for scr_add_item... if you are not meaning to call that....for example if you made the mistake of setting state to 0 to mean "no script" but 0 is a valid script index.... use show_debug_message(state), look at the value... now look in the script resource tree, find the script there that is at the position value is set. if 0, that's the first script. if 1, that's the second in the treeview
 
Top