Multiple Inheritance, event_perform_object trick, but with Variable Definitions in 'Parent' objectS?

N

Niall Edwards

Guest
OK, forgive me as I am new to GameMaker Studio 2 and the forums so I hope people understand what I am getting at.

Firstly, imagine the wonderful Variable Definitions option on Objects did not exist.

I had been using event_perform_object 'trick' to pull down clusters of variables from multiple 'parent' objects into a 'child' object, overriding values at the child object level, and on from there. Thus, lovely multiple inheritance. Of course, I had been setting out those various variables in the multiple 'parent' objects in the Create event Action, not the Variable Definitions.... hmmmm.

Then I started to wonder.

Could I rather set out those same 'parent' object variables in the 'parent' object 'Variable Definitions' area instead of the Create event Actions of the 'parent' object?

Here is the question though --- If I did that, which would otherwise be preferable, could I though 'inherit' those variables into a child object using the event_perform_object trick I had been using before? If so what event on a 'parent' object would I be calling from the Create event Action in the 'child' object? Indeed, with the 'parent' object, what is the event I would be calling to inherit variables if the variables are created in Variable Definitions and not in the Create event Action?

[edit] Also, can I set up a variable in the Create event Action AND also set up the very same variable in Variable Definitions? It's a massive effort, but, if possible, would this be a way around the above?

I really hope I am explaining myself enough here - probably not! As I say, I am new to GMS2.....
 
Last edited by a moderator:

FrostyCat

Redemption Seeker
I don't think that's supported at the moment. The best approximation I know of is copying in the variable definition values one-time from non-immediate parents and using that as an override, but that won't sync automatically the way it can with the immediate parent.
 
N

Niall Edwards

Guest
I don't think that's supported at the moment. The best approximation I know of is copying in the variable definition values one-time from non-immediate parents and using that as an override, but that won't sync automatically the way it can with the immediate parent.
@FrostyCat ,. Thanks for the response. I guess I am going to have to go with old school approach then if no-one has any other thoughts...
 

Yal

šŸ§ *penguin noises*
GMC Elder
You could mimic aspect-oriented programming by having "init" scripts that create instance variables (not vars, lingering variables), it works well as long as you don't rely on is_ancestor() and automatic event inheritance. And if you have only chained parenting (and not "trees" of parents), event_inherited() chains as well (if parent runs grandparent's inherited event this way and child runs parent's, the child will run both the grandparent's event and its parent's event. event_inherited() rocks when used correctly)
 
Top