How do I pick instances with set text?

  • For example:

    I have 2 instances of the same object in the layout and it have an instance variable on it. And I have a "index text" too, to show me if this instance variables are true or false.

    But here is the problem: in the text, if I call this instance variable, it will always be the one of the first object.

    So.. if the first object in the layout have the intance in false and the other object in true, the text will always show me 'false'.

    How can I pick the IID that I want in a text?

  • Try invert the trigger.

  • Well, there's a lot of ways to pick things. This .capx includes two methods.

  • Thank you guys, but I understand that. My problem is how to do that with an expression.

    How to get the right instance index ID of an object in an expression.

    Example: I have three instances of the same object in the layout. And it have a variable called IsFull. So, to show it to me:

    EVERYTICK - SET TEXT TO - "Variable IsFull: "&Object.IsFull

    ^ But I want that information from the 3 instances of the object that I have in layout, and not just from the "0" instance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use a container, but it works best when objects are created dynamically.

  • You can use a container, but it works best when objects are created dynamically.

    Hmm ok

    And thanks for the example

  • I think I understand now? This does what you want, but it still uses multiple conditions:

    On trigger: Set Text to ""

    (Subevent) System -> Foreach Object | Text -> Append "Variable IsFull: "&Object.IsFull & newline

    If you only want to pick certain objects, then put System -> Pick by evaluate in the same block.

  • Unnatural20

    Ah, that's perfect

    Thank you

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