Add ObjectName as an object condition

There’s already an ObjectName() expression. It would be so helpful if it was also a condition.
Yes, you can use ObjectName() with the compare 2 strings condition but that doesn’t pick matching objects. You need to put the condition inside a for each object, and that’s not as efficient.

image

Also, it would be easier to just click if from the list of conditions
Currently you need to add a for each object and compare 2 strings condition
ScreenRecorderProject39_1

If you can’t use ObjectName() as a condition then you also can’t do something like pick a random object based on a variable.

The other option is to create an object variable named name for each object and use the object variable condition. Adding object variables to each object seems unnecessary and redundant since objects already have a name parameter.

7 Likes

Maybe im just being a bit slow, but how would you use it?

From what i understand you want a condition that just states, "If Object Name = “insertName”…

Oh! Is it so you can do stuff with variables? like "If Object Name = “Name+Varibale(color)”, or something along those lines?

That would save a bunch of events if dealing with lots of different objects, you could program all sorts of systems using very little event processing.

Or am i missing the point?

1 Like

Yes. The main use is to pick objects by their name similar to the create object by name. They go hand in hand. You can check the animation or text but not all objects have that option and adding object variables can be a pain.

2 Likes

This has my vote then!

Honestly, anywhere expression like that can be added it should be added.

Using expressions to combine variables into values makes stuff so much easier, clean and efficient.

I was just going to request this as a feature then I saw your request.

This is exactly what I do and I always wished this was a built in condition, which also allows picking objects in a group by their name.

1 Like

If there is an expression, there is likely a way to make the condition yourself, even tho I like this request. I used to have a variable with the objects name in it to discriminate by name.

There’s an expression that can get the name but when used in a compare 2 strings condition, it doesn’t pick the matching objects. It just evaluates the comparison. The same is true for functions.

The only way I know of making it a working condition would be to use the strategy used in the object picking extension. It uses Javascript to create a pick list. (you could also use a for each object but that clutters up the code and wouldn’t be as smooth or efficient as a single condition)

A much simpler method would be if the programmers behind GD made objectName both an expression and a condition. Then you wouldn’t need to add an extension each time or use for each object. It would also be future proof in case something would happen that make the extension incompatible.

Edit: I will also use an object variable to identify objects but setting it up is another unneeded step.

1 Like