Using picked SOL in other parts of event sheet

Get help using Construct 2

Post » Sun Jun 09, 2013 6:41 pm

Is there anyway to send a selected object list to a function, or otherwise use it anywhere else in an event sheet, other than the event it was picked from?

For example, say I was making a game where I was catching butterflies with a net.
Let's say that I caught (picked) several of the butterflies on screen with one swing, but I only wanted to keep the largest one.

I'd want a function like GetLargestInsect, in order to not have a bunch of nasty code with local variables, loops, conditions, in the middle of a simple event like swing net. I could isolate it, and more importantly, I could reuse it, instead having the same code in multiple places.

Is there any way to send the selected object list to the function, without populating a temporary global array with UIDs?

Thanks
B
11
S
2
Posts: 54
Reputation: 805

Post » Sun Jun 09, 2013 7:18 pm

I would give the objects a Boolean instance variable and call it "picked". Just set it to true in any event and you can select the same objects elsewhere by comparing the instance var.
B
89
S
30
G
95
Posts: 5,157
Reputation: 63,450

Post » Sun Jun 09, 2013 7:40 pm

Pretty clever R0J0hound, I like your thinking.

It's still a hack though, opposed to properly referencing an array of instances that already exists.

It sounds like your idea is the best one so far.
B
11
S
2
Posts: 54
Reputation: 805

Post » Sun Jun 09, 2013 8:00 pm

rexrainbow's Instance Group is very handy for this kind of thing.
ImageImageImage
B
71
S
21
G
203
Posts: 3,582
Reputation: 115,008


Return to How do I....?

Who is online

Users browsing this forum: LeuNoeleeste, The Mnk and 11 guests