Eliminating Objects that have the same name

Get help using Construct 2

Post » Wed May 06, 2015 4:41 am

In my game, I create a lot of objects (around 100) with randomly generated names composed from a list of strings. Is there a way to see if two objects have identical names, and then destroy them if they do?
B
5
G
1
Posts: 10
Reputation: 920

Post » Wed May 06, 2015 7:10 am

If they are different objects, they cannot have the same name.
If they are same objects (Create Object), then they ALL would have the same name.

Distinguishing and corresponding to a specific object then would be through its UID (Unique ID) or "Picking by near/far" etc. feature.

Otherwise, there is no 'expression' to compare "names" of Sprites, but there are ways around it.
B
10
S
2
Posts: 109
Reputation: 982

Post » Wed May 06, 2015 1:32 pm

Your best solution is not to use the same name in the first place - that is, when the name is used, remove it from the list.

Here's one quick example, picking one extra index to show that all of the names were used (result is 0).

www.blackhornettechnologies.com/Constru ... rings.capx
ImageImageImage
B
71
S
21
G
229
Posts: 3,686
Reputation: 128,336

Post » Wed May 06, 2015 8:01 pm

You could try picking them via

If Object StringName == "Uniquename"

random <value>

if value > a 50% of that
& Object StringName == "Uniquename"
pick random instance

Destroy

Of course if you have 20 of these guys with the same name you'd have this run alot.
B
2
Posts: 5
Reputation: 160


Return to How do I....?

Who is online

Users browsing this forum: Lightstone, rayolf and 33 guests