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

Cannot call script

K

krugen

Guest
Hi, I'm new to GMS2 and I am using the trial version now. This is the error I receive:

upload_2019-2-23_22-38-42.png


This is the script:
upload_2019-2-23_22-44-12.png

This is the button:

create event:
upload_2019-2-23_22-44-56.png

left_pressed event:
upload_2019-2-23_22-45-32.png

step event:
upload_2019-2-23_22-46-11.png

Please help me out guys. It is driving me crazy.
 

chamaeleon

Member
Hi, I'm new to GMS2 and I am using the trial version now. This is the error I receive:

View attachment 23391


This is the script:
View attachment 23393

This is the button:

create event:
View attachment 23394

left_pressed event:
View attachment 23395

step event:
View attachment 23396

Please help me out guys. It is driving me crazy.
Is it really easier to create and post screenshots than copy and paste text in CODE blocks?

Your issue is derived from not understanding what arguments script_execute() takes, and the fact that you are calling your script right at the point where you are passing it to script_execute() due to using parenthesis. Omitting the parenthesis, and passing the arguments required for it in the script_execute() call instead, is the right way of doing it. Right now, your script returns a number, and that is what script_execute() is currently trying to interpret as a script index and execute.
 
K

krugen

Guest
Hi, chamaeleon. Omg, you saved me. Sorry about the screenshots.

So I followed your advise, I'm sure you have tested it or so:

Code:
answer = script_execute(scr_aplusb(), num1, num2);
to

Code:
answer = script_execute(scr_aplusb, num1, num2);
It worked. Thank you so much, chamaeleon.
 

chamaeleon

Member
Hi, chamaeleon. Omg, you saved me. Sorry about the screenshots.

So I followed your advise, I'm sure you have tested it or so:

Code:
answer = script_execute(scr_aplusb(), num1, num2);
to

Code:
answer = script_execute(scr_aplusb, num1, num2);
It worked. Thank you so much, chamaeleon.
Not a problem. You do know that in this particular case that you show code for @Dmi7ry's code would work just fine, right? I just assumed your end goal was more complex than just doing the equivalent of a function call.
 
K

krugen

Guest
Not a problem. You do know that in this particular case that you show code for @Dmi7ry's code would work just fine, right? I just assumed your end goal was more complex than just doing the equivalent of a function call.
I just want to call and pass argument to the said script.
 
Top