[Help] Object Picking Not Working with Tokenat?

Get help using Construct 2

Post » Tue Apr 29, 2014 4:34 am

After a looooong and frustrating gloss over the math functions in my program, I realized finally that picking objects by IIDs using, say Sprite(0).X does not work when I try to get the data using Sprite(int(tokenat(Sprite.string, 1, ","))).X by running the below events with more than one object at the same time.

So I'm fairly sure that either nothing is happening, or it is picking incorrectly, because the expected results when I just do it by hand never occur.

Here is an illustrative example: Image

Basically, the reticle sprite is created as expected when I activate and populate my "actionQue" one at a time. However, when I populate both at the same time, it can suddenly not correctly pick the data of the object with an IID of 0.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,816

Post » Tue Apr 29, 2014 5:22 am

You need at least a "For each" right after your pick so you can iterate over each instance.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Tue Apr 29, 2014 9:54 am

Hello friend.

Lets assume your first picking picks 10 out of 100 objects. And your second pick in a sub event is trying to pick another instance which was NOT amongst the picked 10. It won't work. The second picking conditions apply only the first picked batch of objects.

You could put "pick all" condition somewhere between. This might be the case here.

Maybe this is the case maybe not, this is what just came to my mind.

You could also run with f6, pause, and run step by step with debugger. Choosing objects from the list show their places and their instance variables, maybe you can figure out what's going on from there.
B
17
S
4
G
1
Posts: 332
Reputation: 3,099

Post » Tue Apr 29, 2014 2:44 pm

blackhornet wrote:You need at least a "For each" right after your pick so you can iterate over each instance.
@blackhornet Yup! That solved it: Image

Though I'm still really stumped. Basically picking in an event and then picking again in a sub-event requires you to tell it to look through the instances again?

@Windwalker yeah that's the same thing my friend suggested when I showed him what I had done in the top screenshot.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,816


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests