GMS 2.3+ Updating your scripts so they run like they used to before GMS 2.3

EvanSki

King of Raccoons
GM Version: 2.3.0.529+
Target Platform: All
Download: N/A
Links: N/A

Summary:
How to Fix old scripts for Gms 2.3

TL;DR Make them functions by adding function (script name) as the first line and enclosing all the code in curly brackets { }
GMS 2.3 should automatically do this for you but in the case it didn't or you don't quite understand.
I hope this helped clear some things up and helps those who are having issues. Looking forward to the new things made in GMS 2.3!

Tutorial:
So you have updated to gms 2.3, the ide runs your project is converted, you've fixed issues, but your scripts are trashed because now they are ran at runtime and saved globally.

Heres a work around i've found so far.

BEFORE 2.3
Your scripts could only hold one function, or act as a bunch of code that can be called by an instance.
before 2.3.png

After 2.3
So because the scripts are now ran at runtime and values are saved globally this will run at the start of the game and show a big 11. Then run again when the object calls it. For this example this isn't to bad, but imagine if this is a save system, or bigger code!
BIG ERROR TIMES!

THE FIX FOR 2.3!
make the old script a function named the same as the script. The Compatibility converter should automatically do this but in case it didn't here's the solution.

wow.png

Essentially that's What you've been doing all along before 2.3! Instead The script acted as only one function and you'd call it as such. "applesaregone()"

by adding function to the start you've made the IDE realize that everything between those curly brackets is a single function, this is still ran and read at runtime but will not be activated until called by the function using an isntance.

I hope this helped clear some things up and helps those who are having issues. Looking forward to the new things made in GMS 2.3!


@matharoo Made a great video on this explaining it a lot better then I can
 
Last edited:

GDS

Member
the funny thing is:

If the function have the same name as the SCR it will be tagged as user_script
if not it will be tagged as game_function

they both works the same, it only mess up the color coding
1597837553173.png

But hey, This update goal IS to mess up your code visually so you feel ashamed to show it to anyone so they will think you have some serious mental problems while coding
 

Neptune

Member
Maybe I'm confused, so "scripts" are just lists of functions now...
Is there really a reason to have more than one script with 2.3? (apart from compatibility scrunctions)
 

EvanSki

King of Raccoons
Maybe I'm confused, so "scripts" are just lists of functions now...
Is there really a reason to have more than one script with 2.3? (apart from compatibility scrunctions)
Scripts are exactly like they used to be, if you think about it as your now able to define scripts in side of one script rather then having 100 different scripts on the asset tree
 

samspade

Member
I prefer to use the name script file as I think it is a better descriptor of what they are now. Not a single script, but a file that can hold between 0 and infinity scripts/functions. (These scripts can then be handled essentially exactly as before except for adding function name([args]) {} around it, or taking advantage of how they work to greatly reduce resource tree clutter.)
 

Neptune

Member
So if I made a script called my_functions, and then defined a bunch of functions inside of the script, I wouldn't really ever call my_functions()
I'd just be calling the individual little functions' names; perhaps using the script is just to choose a global scope for the functions it contains?
Interesting!
 

EvanSki

King of Raccoons
So if I made a script called my_functions, and then defined a bunch of functions inside of the script, I wouldn't really ever call my_functions()
I'd just be calling the individual little functions' names; perhaps using the script is just to choose a global scope for the functions it contains?
Interesting!
doing that and calling my_functions() im not sure what that would do, but im assuming not anything

but lets say you have a function that adds two numbers in the script my_functions() named add()

you'd call add() and give it, it's arguments and it would function just as if you had a jsdoc script set up for the function in 2.2
 
Top