Access any object using UID at any time?

For questions about using Classic.

Post » Fri Feb 26, 2010 7:14 am

Hello, all!

A slightly technical question, can't really find anything similar here.

Is there a way to access ANY object by its UID inside any expression?

As an example, if we knew the UID of an object and needed to get its X coordinate from some event where this object never even comes up, could we do something like this:

AllObjects(UID).X

Maybe I'm just used to a similar approach from some macro programming, but if there was a way to access things using indexes easily that' d be awesome. If there isn't this is a nice feature to have :)
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Feb 26, 2010 6:15 pm

If I recall correctly there is a way to do this using Python. I'm no Python expert though, so I couldn't even begin to explain how :P. As for events, no... you'll have to pick the object by it's UID in a condition like everything else.

[code:3kssq59o]
+ Sprite: Unique ID is whateverValue
-> Set or Get Sprite.X
[/code:3kssq59o]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Feb 26, 2010 7:29 pm

Yeah, that's a shame. A quick way would have been really handy.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Feb 26, 2010 7:44 pm

If you catch Lucid in chat or he sees this thread he might be able to help. He knows lots about python.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Fri Feb 26, 2010 8:06 pm

Will have to do that. I was sort of hoping for, say, Ashley to say something like: "Ah, right, just do this...", though :)
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Feb 26, 2010 8:22 pm

From what I understand that would take a deal of rewriting within Construct. However Lucid did mention that it should be possible to make a plug that would do that for you.
This defiantly something needed for C2.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Feb 26, 2010 9:07 pm

Is it really that useful? All you need is a subevent - compare UID - then you do whatever you need in that event, and it affects the instance with the matched UID.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Feb 26, 2010 9:14 pm

Guess that's an option. Limits it a bit to whatever gets picked in that subevent and needs the sub event itself.

The direct route would be nice.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Feb 26, 2010 9:21 pm

Well one of the problems with picking by uid is that you have no direct way to tell what a particular multiples uid is. Pythons sprite[index] makes that really easy, because the index is based on creation.

Then if you wanted to use something like the Custom Movement Behavior's restrain distance from object, you still have no way to specify which instance you want it to choose.... Unless you use the family hack.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests