So functions are like scripts, except they're easier to set up, organize, and pass arguments to? I'm only afraid of avoiding new features out of not knowing how much better they are. Helpful video!
Woah, this is a huge overhaul.....will scripts need to be function wrapped after the change, or does it automatically detect that there is code in the script and assume the wrapping based on the name?
When you import an older project into 2.3, it automatically wraps all your scripts inside functions. And yes it uses the script name. So your functions don't break on import.
@@GameMakerStation So if you write an "old" script when following a tutorial, you must create a new template project, paste the old scripts into that, then restart game maker, and "import" the new template project, hope the scripts get updated? LOL
So, basically, now scripts will start to act like libraries in any other language? I mean, they can contain macros, static variables and functions, and they are initialized with the game rather than being called, so, pseudo library?
Hey man! So would it work to write the functions in global format like so: function global.GetName() , or is it only possible with global.GetName() = function() ? Thanks!
The global ones do. And we'll probably be getting optional argument support in JSDoc. This is great because the new named arguments support optional args, so if you don't pass in an argument, it doesn't crash, and simply makes it "undefined".
Nice info for those of us waiting for beta access ;-) Do functions work with object inheritance? Say I define a function GetName() in an object oCharacter and oPlayer and oEnemy both have oCharacter as their parent object. Is GetName() available in both child objects oPlayer and oEnemy and does it output the proper object name? That would be a real life changer and one could have inheritance of functions and write way better and more secure code...
@@homunculus1984 Thanks for the reply. That's a pity that overriding the event messes up the function declarations...So I better use some obscure event (user_15) and put all my functions to be inherited in there ;-) There really should be a clean way to write functions for objects that are working across all child objects and not be "corrupted" in any way. I want common method inheritance like in any other OO programming language (Java, C#, ...).
@@homunculus1984 Are you sure? They should be compiled before I start a game, like any other code for any event - so why should they have to run once? I'd guess the Compiler should do that job. Rethinking that even calling event_inherited() shouldn't mess functions up but should define the same functions (if not reusing them cause they didn't change) for the child object. Do you have the beta and could verify that? Or Matharoo? Otherwise it wouldn't make sense to me at all honestly...
RightAngleGames I’m sure. Functions inside scripts do run before anything else, but methods (functions bound to instances or structs) need to run, they are like resources in this sense, they need to be created, they are not parsed on game start. Behind the curtains, doing function foo() {..} in an instance is like doing foo = function() {...}. You’re declaring a variable. And the variable starts to exist only at the time it is declared.
This was a bit of a bane for my project! I had planned my game using scripts as code containers, so that i have all code organized in script folders, now i find "functions" in all scripts that i created! Sure, the game still works, but in every script page it generated whitespace before each string which I find very irritating.
Thanks for watching! Make sure to join our Discord server if you want to discuss the new beta -- we've got #beta channels! discord.gg/TykHyqK
Quarantine is making YOYOgames' team quite productive.
You are starting to become my favorite GM UA-camr.
Thanks for this. I had used GM1 and made a loot of small games in the past now I am having to play catch up with all the changes.
Very interesting. These changes make GML more familiar.
I'll give another chance to GM. :)
as usual, another absolutely stunning tutorial
So functions are like scripts, except they're easier to set up, organize, and pass arguments to? I'm only afraid of avoiding new features out of not knowing how much better they are. Helpful video!
Great job! I was wondering how exactly the 'static' keyword is working in 2.3.
Cant wait for the structs tutorial!!
You are the best. YoYo games should give you a job.
Woah, this is a huge overhaul.....will scripts need to be function wrapped after the change, or does it automatically detect that there is code in the script and assume the wrapping based on the name?
That's an excellent question... o_O
When you import an older project into 2.3, it automatically wraps all your scripts inside functions. And yes it uses the script name. So your functions don't break on import.
@@GameMakerStation So if you write an "old" script when following a tutorial, you must create a new template project, paste the old scripts into that, then restart game maker, and "import" the new template project, hope the scripts get updated? LOL
So, basically, now scripts will start to act like libraries in any other language? I mean, they can contain macros, static variables and functions, and they are initialized with the game rather than being called, so, pseudo library?
Yep
LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL
@@rodrigo1593_ ?
@@m1s3ry97 (*HAPPINESS**)
Good job! Greatings from China
I love your videos, thanks for your work!
Im having a REAL pain in the ass trying to figure out how to convert pre-2.3 scripts from tutorials etc, to work in 2.3 =(
Really informative!
Can you do something like "static return RandomNum" to only get the writeout in the output log ONCE, rather than every frame?
static a = log("One time log)";
Can't wait for structs video.
Hey man! So would it work to write the functions in global format like so: function global.GetName() , or is it only possible with global.GetName() = function() ?
Thanks!
A+! Thanks for the information
My only question is, can I bind a global/script function to an instance using method()?
I think so, but I can't say for sure.
what is your intro song
One I made myself: soundcloud.com/gurpreet-singh-matharoo/gamemakerstation-outro-extended
Do you know if the new functions still support the JSDoc comments?
The global ones do. And we'll probably be getting optional argument support in JSDoc. This is great because the new named arguments support optional args, so if you don't pass in an argument, it doesn't crash, and simply makes it "undefined".
Great news all round. Thanks for the answer.
Nice info for those of us waiting for beta access ;-)
Do functions work with object inheritance? Say I define a function GetName() in an object oCharacter and oPlayer and oEnemy both have oCharacter as their parent object. Is GetName() available in both child objects oPlayer and oEnemy and does it output the proper object name?
That would be a real life changer and one could have inheritance of functions and write way better and more secure code...
Yes, as long as you don't override the event defining the function, or call event_inherited inside of it
@@homunculus1984 Thanks for the reply. That's a pity that overriding the event messes up the function declarations...So I better use some obscure event (user_15) and put all my functions to be inherited in there ;-)
There really should be a clean way to write functions for objects that are working across all child objects and not be "corrupted" in any way. I want common method inheritance like in any other OO programming language (Java, C#, ...).
@@rightanglegames The function declarations have to run, you can't just put them in a user event and never run it
@@homunculus1984 Are you sure? They should be compiled before I start a game, like any other code for any event - so why should they have to run once? I'd guess the Compiler should do that job. Rethinking that even calling event_inherited() shouldn't mess functions up but should define the same functions (if not reusing them cause they didn't change) for the child object. Do you have the beta and could verify that? Or Matharoo?
Otherwise it wouldn't make sense to me at all honestly...
RightAngleGames I’m sure. Functions inside scripts do run before anything else, but methods (functions bound to instances or structs) need to run, they are like resources in this sense, they need to be created, they are not parsed on game start. Behind the curtains, doing function foo() {..} in an instance is like doing foo = function() {...}. You’re declaring a variable. And the variable starts to exist only at the time it is declared.
Dowlord 2.3 ?
This was a bit of a bane for my project! I had planned my game using scripts as code containers, so that i have all code organized in script folders, now i find "functions" in all scripts that i created! Sure, the game still works, but in every script page it generated whitespace before each string which I find very irritating.
why put a small heart on my comment? what does it mean? you love me?
Awesome content, love it! =)
Good stuff!
Function is a game changer. So need to create script files for small features anymore...
Gamemaker becomes more rational
GameMaker Studio 3
:D Hell yes!
ooooo okkkkk
This is too much for a beginner like myself.