Select object by its name and variable value

Hello Dear,
Can you help me?
How can I select an object by its name plus a number variable?
Let me explain:
support1, support2, support3, etc.
I’m running a loop and want to use a number variable that increases with each pass. So, I’d like to select the ‘support’ + the number (concatenation).
Do you have any ideas?
Many Thanks in advance.

Remy

You’ll have to put all your objects into an object group, and then iterate over each object in the group comparing against the target name.

I defined ObjectGroup as:


and select the object with these events (loop is my variable number):

Perfect, thanks a lot.

Remy

Dear MrMen,

Again a little help please.
Can you show me how I can (see picture) select the .X position and .Y of the object?

Thanks a lot,
Remy

If you put something in quotes, it literally gets taken as that string and not evaluated. So this:
image
is just the string/text “ObjectGroup.ObjectName()”, not what it evaluates to, because it is surrounded by quotes. To GDevelop, it’s similar to “Hello World” in that it is just a string/text. To GDevelop it is just text and nothing else.

ObjectName() is a function that returns the name of the object. If that object is a group, then it returns the name of that group object. You need to replace “ObjectGroup.ObjectName()” with grpPlaceholder.ObjectName()


For the action, “.X()” and “.CursorY()” needs to be on an object, not the string name of an object. In that loop, the object is represented by grpPlaceholder. So this:
image

should be grpPlaceholder.X().

Wouaw! Again thanks a lot.

Remy

Hey i have a problem in the code like you have. Lets say i have multiple instances of the object House. They are all belong the group called Tiles. Every created instance of a House has a Value and Index. Index is like ID for every created House. So when i lets say press button i want to calculate every Value of every house one by one. So i did:

And it works only for the first house. CurrentIncomeIndex changes to 2 and thats it. How can do calculations and animations for every object of a group “one by one”?

The house objects may not be iterated over in order of Index. Say you have 5 house objects. If the first one has an index of 5, the second one an index of 4, the third 3, the fourth 2 and the fifth house has an index of 1, then it only works on the last house.

The CurrentIncomeIndex is actually redundant in those events. Just take it out of the conditions and actions.

1 Like

I put all into a group (see picture)
I don’t understand why sometime it works for 3 or 4 or…!




Is there anyone who might have an idea?

This is the principal scene

Your problem is the same as @Bulldor’s problem, except with an object name:


My question would be why do you need to check the grpPlaceholder’s name? It’s not like a specific card is placed on it. Remove the condition checking the grpPlaceholder name and also remove the action incrementing holdernum. They are both unnecessary.

Also, you could be picking a card that is already moving. You need to add the condition that the Card object does not have the tween “FlyIn”.

I will try, thanks a lot