I just found this channel yesterday and since then I watched like 10 videos. It's amazing, you speak about some more advanced stuff that I used to be confused about or I didn't know at all. You deserve much more views than this!
Thanks for always making these great tutorials! Just finished your 3D series, and I’ve learned a ton and you explain it all really well. Can’t wait for future streams and videos!
You can actually call parent methods by adding new variables to the children and assigning needed methods to it before overriding anything. It sure is messy way but what to expect from GML. And tbh I’m glad that at least one way exists.
I want to say something like "yeah but that's not really calling a parent method so much as putting the old ones in a bin for later," except that's pretty much the entirety of GML in some way or another lol
Is it possible to call the parent method in a method? For example Animal.speak() gives "i'm an animal" Doggo extends Animal; Doggo.speak() returns parent.speak() + "and also a doggo". So if you would call Doggo.speak(), it would return "i'm an animal and also a doggo"
Sadly there isn't. There are a few clever tricks you can use like creating a stack of inherited methods with every level of inheritance you can call, but there's nothing built-in.
When I heard they were putting structs in, I was like "YAY!! FINALLY!".....then I noticed 2 keypoints: 1. couldn't make a coherent "interface" style coding, would have been nice to be able to test a struct on whether it contained certain methods before calling those methods. This is definitely lacking in GMS. Something as simple as "if(mystruct is chestinterface) mystruct.openchest()". At the moment, I have to resort to wasting variables inside all objects and structs as a bitflag for what "interfaces" that object/struct has available. 2. pointer referencing becomes clunky.....I require a double-linked list for certain things, and as easy as it is to program in almost every other language, it's horrible in GML. I honestly am not even sure if structs are referenced, but rather store as-is when you set it, which means it's more like cloning (couldn't get it to work). I end up using buffers for space optimizing, but it's slow. Which means, structs are almost worthless, and disappointing. :(
Interfaces (and static typing things in general) would definitely be very nice. Given that methods are just variables containing functions you can use variable_struct_exists and / or is_method to check if a struct contains a method, but the first is comparatively slow and I don't like both on the grounds that they encourage people to write spaghetti. Structs are stored by reference, so I don't think referencing them is really that bad in most cases. If they weren't, the way arrays (sometimes) aren't, that would be a NIGHTMARE.
All doggos are good doggos, and a pox upon he who dares to say otherwise.
I just found this channel yesterday and since then I watched like 10 videos. It's amazing, you speak about some more advanced stuff that I used to be confused about or I didn't know at all. You deserve much more views than this!
Thanks for always making these great tutorials! Just finished your 3D series, and I’ve learned a ton and you explain it all really well. Can’t wait for future streams and videos!
You can actually call parent methods by adding new variables to the children and assigning needed methods to it before overriding anything. It sure is messy way but what to expect from GML. And tbh I’m glad that at least one way exists.
I want to say something like "yeah but that's not really calling a parent method so much as putting the old ones in a bin for later," except that's pretty much the entirety of GML in some way or another lol
Is it possible to call the parent method in a method?
For example Animal.speak() gives "i'm an animal"
Doggo extends Animal; Doggo.speak() returns parent.speak() + "and also a doggo".
So if you would call Doggo.speak(), it would return "i'm an animal and also a doggo"
Sadly there isn't. There are a few clever tricks you can use like creating a stack of inherited methods with every level of inheritance you can call, but there's nothing built-in.
9:00 NICE
Is their anyway to inherit more than one parent. This would be awesome
nope, interfaces may or may not be in the works though
I wish I could type code that fast ~/o/
When I heard they were putting structs in, I was like "YAY!! FINALLY!".....then I noticed 2 keypoints:
1. couldn't make a coherent "interface" style coding, would have been nice to be able to test a struct on whether it contained certain methods before calling those methods. This is definitely lacking in GMS. Something as simple as "if(mystruct is chestinterface) mystruct.openchest()". At the moment, I have to resort to wasting variables inside all objects and structs as a bitflag for what "interfaces" that object/struct has available.
2. pointer referencing becomes clunky.....I require a double-linked list for certain things, and as easy as it is to program in almost every other language, it's horrible in GML. I honestly am not even sure if structs are referenced, but rather store as-is when you set it, which means it's more like cloning (couldn't get it to work). I end up using buffers for space optimizing, but it's slow.
Which means, structs are almost worthless, and disappointing. :(
Interfaces (and static typing things in general) would definitely be very nice. Given that methods are just variables containing functions you can use variable_struct_exists and / or is_method to check if a struct contains a method, but the first is comparatively slow and I don't like both on the grounds that they encourage people to write spaghetti.
Structs are stored by reference, so I don't think referencing them is really that bad in most cases. If they weren't, the way arrays (sometimes) aren't, that would be a NIGHTMARE.
😅❤👍