Legacy GM (SOLVED) Quick query with regards to object parents?


Hi Everyone!

I was planning out some objects in a project --and planning some parental hierarchies--and stumbled across a query I have never got to the bottom of: When it comes to parents, children, and inhereted code/events, do parents or children 'overwrite' certain blocks of code or events?

From memory, a child;s code will overwrite that of its parent if it is conflicting (i.e, setting a variable within a child will overwrite any variable settings set by a parent), but I was wondering how this played out in events. For example, if I have a parent object with a 'create' event, which establishes some general variables, and then a child object also has a 'create' event, which establishes a second set of variables particular to that object, will this overwrite the parent's 'create' event and mean that the original variables are never established?

Sorry for possibly asking some basics, but I couldn't seem to find the answer in the docs page for parents, and figured I'd bring this query here!

Thanks in advance for any insight!

Kind regards,
Yes, the entire child event takes over from the parent event. The parent event is not called if there is the same event defined in the child.

If you still want the parent event to run, you need to put the command event_inherited() in the child event, which cause the parent event to be run at that moment. So normally you would put event_inherited as the first line of your child event if that what you want to happen.
Just to make it clear in case it's not obvious, if you put event_inherited() as the last line in your child object event, all the code in the child will run first, then, when GMS gets to that last line, it runs the parent event code.