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

SOLVED What does a function in a script do without arguments (in GameMaker 2.3)?

jobjorgos

Member
What is the difference between script example A and example B?

Example A
script_jump:
GML:
function scr_custom_input_menu_character_jump(){
    do_character_jump=1;
}
Example B
script_jump:
GML:
function scr_custom_input_menu_character_jump(){

}
do_character_jump=1;

I have script_jump in the step event of the player, but somehow ONLY in Example B the variable do_character_jump gets the value 1.
Does a function do anything at all without arguments?

The reason I use scripts, is because I don't want 25000 rows of code in the players step event, but put most code in 'container' scripts to keep a clear overview
 

Nidoking

Member
Um... the second script has the body of the function outside the function. That's the difference. You don't put script_jump in the step event of the player - you put a call to the function scr_custom_input_menu_character_jump() if that's what you want to do.
 

samspade

Member
To answer your original question in another way, saying:

GML:
function scr_custom_input_menu_character_jump(){
    //code or no code
}
declares a function, it doesn't call it and the code inside of it doesn't run until you call it. To put it yet another way, it's the difference between creating and using the function.
 
Top