Compare texts of different instances

Hey I have 7 of the same text object and I randomly select a name for each of them but I need it so there can’t be duplicates but I can’t figure out how to make it re-roll when they get duplicates

In this example I have just the three, I swear you used to be able to compare text variables but can find it.

You can’t compare the values of different instances because GD doesn’t know which ones you want.

In your situation, it’s using a for each instance. That event picks 1 object at a time. It’s comparing the object to itself.

You could use a variable to save the value of 1 object and then compare it to the others. I would put the possible texts into an array and either shuffle the array or pick random target objects. There are multiple ways to randomize things without repeating.

Do you want to add one text value on each click or are you adding all of the texts at once.

1 Like

I add all the texts at once.

I know it is picking itself I tried using the for each instance and the pick all conditions but it was to no avail

This uses an array called List.

Or using the array tools shuffle with a scene variable array. You can’t use a local variable with array tools.

It’s easier to use an array and either shuffle the array using array tools or pick random target objects than using what I would call a brute force approach. The brute force technique is like a hacker trying every password. The number of tries is unpredictable and would probably require a while event or nested for each instances with a pick all. Even then, it would be repetitive.

1 Like

I’m on a business trip I will do this the second I get home, I’ve never used an array but I will do my best and come back with my error

Thank you for your time and assistance

1 Like

I’m still not getting it.

How does it no not to have two with the same name, and I also don’t get the difference between array and list. Also I tried just copying and mine does not have the delicate condition yours has.

I really appreciate your help I’ve never made anything quite like this and I’m struggling hard

I don’t know what you mean by that.

In my example, List is the variable name and it’s an array. If that’s what you’re asking.

Which condition? Are you talking about the declare lines. I used local variables. You could use scene variables.

Can you post a screenshot of your events.

https://wiki.gdevelop.io/gdevelop5/all-features/variables/local-variables/