Given a UID how do I find what object it is?

Get help using Construct 2

Post » Wed Jul 06, 2016 1:26 pm

Hello;

Suppose I want to know if a UID is a sprite or a text box?

How do I find the string of the object name, ie "sprite" from a UID value? Its possible the UID may not be an
object instance.

thanks for your time
yours
Winkr7
B
33
S
8
G
3
Posts: 169
Reputation: 3,280

Post » Wed Jul 06, 2016 4:28 pm

You can attempt to pick it from the sprites using 'pick by uid', then do an 'else' afterwards in-case it doesn't get picked. That way you either know it is or isn't in the sprite.
That's the only way I know how to do that sort of test.
Or you could create an array of uids for sprites whenever a sprite is created, and check the array for if the value exists. That second way might be more flexible?
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Wed Jul 06, 2016 6:51 pm

+System: Object UID exists
B
53
S
11
G
6
Posts: 133
Reputation: 8,830

Post » Wed Jul 06, 2016 7:53 pm

siks, he doesn't want to know whether it exists or not. He wants to get the object type based on the given uid.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Wed Jul 06, 2016 11:42 pm

On all objects, add a "type" instance variable. On creation of any object, set the variable to object type. Now when you pick by UID, you can look up self.type by expression.

... maybe? Just an idea.
Mistakes were made.
B
48
S
23
G
107
Posts: 1,576
Reputation: 60,168

Post » Thu Jul 07, 2016 12:35 am

+ sprire (family) : pick by UID
- actions for sprite types

+ else
+ textbox (family) : pick by UID
- actions for textbox
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Thu Jul 07, 2016 4:31 am

@Prominent it was an idea to start. I think I'd check by "Pick by UID" on each object. Like rexrainbow said.
B
53
S
11
G
6
Posts: 133
Reputation: 8,830

Post » Thu Jul 07, 2016 12:21 pm

Hello;

Thanks for the helpful replies.

yours
winkr7
B
33
S
8
G
3
Posts: 169
Reputation: 3,280


Return to How do I....?

Who is online

Users browsing this forum: timoteomorelli and 1 guest