How do I pick instances with set text?

Get help using Construct 2

Post » Wed Feb 11, 2015 6:43 am

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?
B
16
S
4
Posts: 367
Reputation: 2,134

Post » Wed Feb 11, 2015 8:36 am

Try invert the trigger.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Wed Feb 11, 2015 9:24 am

Well, there's a lot of ways to pick things. This .capx includes two methods.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Feb 11, 2015 4:40 pm

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.
B
16
S
4
Posts: 367
Reputation: 2,134

Post » Wed Feb 11, 2015 4:50 pm

You can use a container, but it works best when objects are created dynamically.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
70
S
19
G
140
Posts: 3,319
Reputation: 82,720

Post » Wed Feb 11, 2015 6:25 pm

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

Hmm ok
And thanks for the example :)
B
16
S
4
Posts: 367
Reputation: 2,134

Post » Wed Feb 11, 2015 7:01 pm

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.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Feb 11, 2015 7:27 pm

@Unnatural20
Ah, that's perfect :)
Thank you
B
16
S
4
Posts: 367
Reputation: 2,134


Return to How do I....?

Who is online

Users browsing this forum: hsetiawan, yenleidong and 3 guests