How do I pick several UID instances at the same time

Get help using Construct 2

Post » Sat Apr 26, 2014 1:42 pm

@blackhornet: Okay I'll follow your suggestion. Thank you for your assistance.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Tue Apr 29, 2014 2:23 pm

R0J0hound wrote:You could do this:
Code: Select all
Event:
Repeat 4 times
Pick instance with UID int(tokenat("0,1,2,3", loopindex, ","))

Subevent:                                 
Animation frame = 3

Action:
Set variable to 1


@R0J0hound: I tried this solution using non-sequential numbers (0,3,7,9,13) and if I click on one of these instances the value of the variable is changed when in fact I need all the related instances have been selected to change this value . What can I do in this case? Thank you.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Tue Apr 29, 2014 2:28 pm

You should never hard code UIDs or IIDs. You don't want to rely on the random chance that they will be the same between sessions.

@blackhornet 's solution is the best, in my opinion.
Don't see the fnords and they won't eat you!
B
79
S
17
G
12
Posts: 323
Reputation: 11,855

Post » Tue Apr 29, 2014 3:32 pm

Hi @Wastrel

I actually thought about using the blackhornet's solution, but this will force me to create a layout for each level. I have 55 squares on the screen and they are combined to generate drawings of different numbers. I will not always use the same squares. If I use a instance variable, I have to change the value of this variable for each combination. So it would be better to access the instances through UID.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Tue Apr 29, 2014 5:48 pm

@RenatoB , yet another way would be to push the uid you want to check in an array, then for each x, pick uid at array.at(curx) and compare whatever
ImageImage
B
71
S
22
G
7
Posts: 827
Reputation: 10,177

Post » Tue Apr 29, 2014 8:11 pm

vtrix wrote:@RenatoB , yet another way would be to push the uid you want to check in an array, then for each x, pick uid at array.at(curx) and compare whatever


@vtrix

But I continue to use UID and in a more complicated way. For me the best would be to use the first blackhornet solution because I need to manage 6~10 instances only:

Code: Select all
Pick instance by evaluating instance.UID >=0 && instance.UID <=3


I changed to :

Code: Select all
Pick instance by evaluating instance.UID=0 && instance.UID =3 && instance.UID =5 && instance.UID =9


But the program does not accept && for this command.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Tue Apr 29, 2014 9:07 pm

@RenatoB did you actually try this condition, i think you can combine picking like this / edit: nope you cant

pick sprite instance 0
pick sprite instance 7
pick sprite instance 5

you could make them variables and update the numbers when needed
ImageImage
B
71
S
22
G
7
Posts: 827
Reputation: 10,177

Post » Tue Apr 29, 2014 10:26 pm

vtrix wrote:@RenatoB did you actually try this condition, i think you can combine picking like this / edit: nope you cant

pick sprite instance 0
pick sprite instance 7
pick sprite instance 5


@vtrix,

I had tried this. BTW, was my first idea.

vtrix wrote:you could make them variables and update the numbers when needed


Okay. It seems that there is no other way.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Wed Apr 30, 2014 12:03 pm

As I said yesterday, I had to use a variable ("register") to distinguish the frames and got the same problem I had with the UIDs. If I click on a square and the frame is correct, the value of the variable "squareRight" is changed. To change this variable is necessary that all the squares with the variable "register" =1 have been selected.

Below is the code I used but that does not work

Code: Select all
Event: Pick all square
Sub-event: Pick square where square.register=1
Sub-event: Animation frame = 3
Action: Set squareRight to 1
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Wed Apr 30, 2014 6:07 pm

Some light, please.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests