How many different instances I can pick in one event?

Discussion and feedback on Construct 2

Post » Fri Jun 17, 2016 3:41 pm

Hi,

Having a bit of a problem with my event's and I'm not sure if picking instance of object A and picking Instance of Object B in same events condition works or not? So how many different instances of different objects I can pick in single condition?

Also is this valuable as trigger, cause it doesn't seam to work for all Objects A, only for the one that got triggered:

-Object A on trigger
-- Object A Boo1 = 1, for each Object A, Object A Boo1 = 1, Pick Object B by Object A. Variable

Thanks
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Fri Jun 17, 2016 3:57 pm

It's hard to know exactly what you want here, but you don't really need "for each Object A, Object A Boo1 = 1" as only the triggered A objects are picked in the trigger anyway, So just picking B by VarA should work, or at worst, you need a For each A, then pick B by A.

Object A on trigger
-- for each Object A, Pick Object B by Object A. Variable

OR if you are adding to the list of "A"s by setting the Bool, then you need a Pick All A to get all of them before the For each that you have. Again, hard to know what you really want from the pseudo-code.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Fri Jun 17, 2016 4:06 pm

@megatronx
I am not aware of any limit in how many instances can be picked in a single condition.

The "For Each Object A" will only loop through the instances that were triggered in the parent event. If you wanted to process all instances you would need to add a "Pick All Object A" line before the loop to clear the filter applied by the trigger event.

There should be no problem also picking instances of Object B. The only time I have had trouble is if you just created new instances. Those can't be picked outside of the scope where there were created until the next top level event.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Fri Jun 17, 2016 4:59 pm

Yes, I want to go trough all instances and then pick those with Boo = 1 and then if boo = 1 pick objects B by objects A variable. So I got to do Pick All then for each and then do IF. I'l try that.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Fri Jun 17, 2016 5:25 pm

capx will be easier....but when it comes to picking instances I like using functions to encapsulate things. It reduces complexity.
B
41
S
17
G
8
Posts: 484
Reputation: 8,261

Post » Fri Jun 17, 2016 8:39 pm

why would you do that?

example - you have these 3 sprites - walls, enemies, player. you have 10 instances of walls, 5 of enemies, 1 of player.

why would you pick each of these instances (including walls) which have var boo ? why would wall even need to be picked ? (in example where you want to check all enemies and yourself)

best would be to use family if you really want all instances, but that family will contain every sprite. it seems wrong whatever you are doing :)
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
41
S
14
G
12
Posts: 623
Reputation: 9,359

Post » Fri Jun 17, 2016 8:56 pm

saiyadjin wrote:why would you do that?

example - you have these 3 sprites - walls, enemies, player. you have 10 instances of walls, 5 of enemies, 1 of player.

why would you pick each of these instances (including walls) which have var boo ? why would wall even need to be picked ? (in example where you want to check all enemies and yourself)

best would be to use family if you really want all instances, but that family will contain every sprite. it seems wrong whatever you are doing :)


On Object B tween ended I need to compare if a string created from several "keys" sent out from several Object's A and received by By object C match required "Key" of Object C. If not, all objects B got to return to their original position via tween, Objects A and Object C got to reset their state. So I need to pick all Objects A within a group, set trough group variable and change their boos and their variables. Basically a switch puzzles that differ depending on their variables. Sometime spuzzle is: switch in correct order, other time, press those leave others, and yet another time it press all, or add item.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Fri Jun 17, 2016 9:40 pm

I suppose the 'string' is an instance variable in object C, and that there is only one object C. If there are more instances of object C, you have to explain wich instance of object C must be picked.

I suppose the string is made and present.

Then (under those circumstances) ....

Trigger for Instance of Object B's tween ended ... sets that that object picked.
There is only 1 instance of object C .. so it does not need picking.
In a sub, evaluate the instance variable of Object C with the string in Object B.
If not true, reset B, it does not need picking.

For the others the easyst thing is to use a Function. Because Functions start picking from scratch.
So, if the evaluating condtion is not true, ....
call a function 'send all B back". In that on function you dont need to pick, just the action to send B back. (when not picked, actions adress all B's)
call a function 'reset all A". In that on function you dont need to pick, just reset A (when not picked it resets all A)

Hope that is clear.
B
33
S
18
G
28
Posts: 2,470
Reputation: 20,904

Post » Sun Jun 19, 2016 6:43 am

"-Object A on trigger
-- Object A Boo1 = 1, for each Object A, Object A Boo1 = 1, Pick Object B by Object A. Variable"

a Pick all instances would be needed before checking if boo is equal to one if you want to apply it to all objects, unless I did not understood fully

https://www.scirra.com/manual/124/system-conditions

Must admit I didn't understood exactly what you wanted to do though so I may be irrelevant
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests