If all instances var value = 0

For questions about using Classic.

Post » Thu Jun 07, 2012 3:04 pm

How would I go about doing this? There must be a really easy way I can't think of right now. Check if at any moment the variable value of all instances of an object are equal to a certain value.Shindoh2012-06-07 15:05:16
B
3
G
1
Posts: 70
Reputation: 615

Post » Fri Jun 08, 2012 6:00 am

Can't think of a really easy way at the moment, but here's a comfortable one:

test_all_instances_match.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Jun 08, 2012 11:34 am

Here's a more simple way: https://dl.dropbox.com/u/52670878/CheckValues.cap
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Fri Jun 08, 2012 12:49 pm

Nice solutions, on both examples.
@Tulamide could you explain, how that "isolated" stuff works oO.
I see 'that' it works, but even after reading the wiki, I didn't get it 'why' it works ><.zyblade2012-06-08 19:11:09
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Fri Jun 08, 2012 8:21 pm

[QUOTE=zyblade]@Tulamide could you explain, how that "isolated" stuff works oO.
I see 'that' it works, but even after reading the wiki, I didn't get it 'why' it works ><.[/QUOTE] It doesn't work. I couldn't ever get it to work.
If you try the examples from the wiki, you will see that they don't work. Simply forget about picking in aliases...

...at least until @ROJOhound comes along and belies me
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Jun 08, 2012 9:47 pm

@tulamide I haven't used function alias' before so I did some tests and looked at the source to see what it does.
Isolated/inline act the same as calling a function with forget/remember picking. Any picking done by the alias is forgotten when the alias returns (I initially thought that "inline" would change the SOL of the event that called the alias, but it's not the case).

Example of use:
+ Function: On Alias "isValue"
-> Sprite: Rotate 45 degrees clockwise

//// all the sprites are rotated
+ Sprite: Pick one at random
+ Function: "isValue" (Isolated)

////only one is rotated
+ Sprite: Pick one at random
+ Function: "isValue" (Inline)


@Shindoh
Here is another method using two conditions.
+ Sprite: Value 'test' Equal to 0
+ System: CountMatching(Sprite.OID) Equal to Sprite.Count
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Post » Fri Jun 08, 2012 10:47 pm

Very interesting, that I am not the only one, who didn't know about that function^^ Thanks R0j0...somehow that sounds corny, maybe because I used that exact phrase too often Dejavu like o.0

Should make a macro for it.zyblade2012-06-08 23:02:09
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sat Jun 09, 2012 1:15 am

[QUOTE=R0J0hound]Any picking done by the alias is forgotten when the alias returns (I initially thought that "inline" would change the SOL of the event that called the alias, but it's not the case).[/QUOTE] Ah, now I see. No wonder I had no success. It's completely the other way round.
The wiki is awfully wrong at describing the workings. Here's from the wiki (most interesting part in italic):
"In Inline mode (comparable to Remember), all currently picked objects are passed to the On Alias event, which can then pick other objects, and pass them back to the calling event again. In other words, with Inline aliases, object picking affects both events."
I was relying on that and never thought in another direction^^
Thank you, @ROJOhound



[QUOTE=R0J0hound]@Shindoh
Here is another method using two conditions.
+ Sprite: Value 'test' Equal to 0
+ System: CountMatching(Sprite.OID) Equal to Sprite.Count[/QUOTE] Now that's a compact, efficient way to do it!
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Jun 09, 2012 3:17 am

[QUOTE=R0J0hound] @tulamide I haven't used function alias' before so I did some tests and looked at the source to see what it does.
Isolated/inline act the same as calling a function with forget/remember picking. Any picking done by the alias is forgotten when the alias returns (I initially thought that "inline" would change the SOL of the event that called the alias, but it's not the case).

Example of use:
+ Function: On Alias "isValue"
-> Sprite: Rotate 45 degrees clockwise

//// all the sprites are rotated
+ Sprite: Pick one at random
+ Function: "isValue" (Isolated)

////only one is rotated
+ Sprite: Pick one at random
+ Function: "isValue" (Inline)


@Shindoh
Here is another method using two conditions.
+ Sprite: Value 'test' Equal to 0
+ System: CountMatching(Sprite.OID) Equal to Sprite.Count[/QUOTE]
Thanks for the great help, everyone.
Rojohound, that is definetely what I was looking for. :)
B
3
G
1
Posts: 70
Reputation: 615


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests