How do I have an action object reference its event object?

  • Edit: Question answered! Families are the way to tackle this.

    ---

    Hi,

    I'm dealing with a lot of redundancy that I bet there's a way to work around.

    I frequently have actions inside of an event whose object needs to be the object of the event. As I work with large numbers of events/actions and work to de-duplicate unnecessary items, it would be very, very helpful to have an action's object simply be "this", or be "this event's object".

    Is that possible in Construct 3? I'm aware that events can have multiple objects, but if there's a way to set action objects as relative references rather than absolute references (to a specifically declared object), that would be very helpful.

    Thanks, everyone!

  • Where does the redundancy come into it? If you're talking about using the same events for multiple object types then you can put all objects in a Family and use the Family for picking.

    I don't know if that's what you're after but when you talk about events that are becoming redundant and you want to pick 'an object' rather than a specific object type then Family works well to refer to any number of specific objects that exist in the Family.

    If this isn't the case then please provide some more example events to demonstrate what is redundant for you. If I've understood it correctly I think what you might be describing though is not possible as Construct works by picking instances of an object type on the left then applying the action to those picked instances. Using Families may get you somewhere close though as objects can be grouped.

    Take a look at how events work, maybe that will be of some use : construct.net/en/make-games/manuals/construct-3/project-primitives/events/how-events-work

  • In expressions you can use Self, but I can't see how a similar concept could apply to actions, since conditions can pick from multiple objects.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, Plinkie! I really should have explained that, better.

    I'm trying to make my code modular. Really, I want to be able to write a set of actions once, and have that actions run on any object(s). I was probably asking if a specific solution was possible, rather than explain the problem.

    Pulling that image back in, again:

    You can see that certain variables in the jobFighter event need to perform certain actions, every time the condition is met. The problem is that I have a lot of parallel objects, running in parallel. I also need to do this for jobMage and jobRogue, etc. (in this case, even though it says "jobFighter", it functions like a skill in my game).

    Rather than have to do this:

    I'm trying to simplify my code, like this:

    This is how I'd try to solve problems in other design platforms I've used. However, if I'm not thinking about this in the proper way for Construct 3, I'd like to learn!

    Thanks,

    El

    --

    Edit: Ashley, I see that you posted while I was typing. Thanks for your response-- it's thrilling to have someone from the Construct team respond! :-)

    Hopefully this post helps to make it more clear what I'm trying to accomplish. I bet I'm simply not understanding something about Construct 3 or best practices for handling this situation; appreciate any guidance!

  • Yeah Families then. Put rogue and mage into a family where Duration and MaxDuration are Family instance variables. You can still refer to the classes separately for some things but for those events you can use single events with family, so rogue.duration and mage.duration become family.duration which applies to both rogue and mage.

  • Yeah Families then. Put rogue and mage into a family where Duration and MaxDuration are Family instance variables. You can still refer to the classes separately for some things but for those events you can use single events with family, so rogue.duration and mage.duration become family.duration which applies to both rogue and mage.

    Appreciate it, Plinkie! I see-- that was a big, missing part of the puzzle. Still have a good bit of configuration to do, but it all seems to be working!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)