Checking the variables of two instances

Get help using Construct 2

Post » Sun Jan 12, 2014 5:44 pm

is there an example capx file anywhere to see comparing instance variables in action?
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

Post » Sun Jan 12, 2014 5:45 pm

Why don't you post your code?
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Sun Jan 12, 2014 7:02 pm

https://dl.dropboxusercontent.com/u/114119373/a-STUFFF/problem.capx

so basically the green columns are sight blockers. I have two enemies- both patrooling in 2 perimeters.

To test it, let the first one see you and then walk to the right until you push it past the green column where the second enemy's parameter is. The second enemy must also become alert when seeing his alert comrade somehow.


thanks in advance blurymind2014-01-12 19:03:09
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

Post » Sun Jan 12, 2014 7:37 pm

Could be me, but alertmodetest is 4 on start of layout and it is never set to 2 so the event if alertmodetest=2 will never be triggered, will it?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jan 12, 2014 7:42 pm

i didnt really replace it completely yet. Just created a test variable instead. To move the alretmode variable to the enemy family, i have to also change it everywhere in the code where its a condition and where it is set.

Will do that if I am sure that it will do something. But im not sure how to do it because not sure how it does it.

blurymind2014-01-12 19:43:47
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

Post » Sun Jan 12, 2014 7:59 pm

So save your capx under a different name and start changing it.
I assure you, if you do it right it will work.

Why should someone else do the work?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jan 12, 2014 8:26 pm

I tried using the alertmode variable in the family enemies instead of in the enemy object. All the enemies froze to disabled.

how does the alertmode variable of the enemy family relate to the alert mode variable of an individual instance of an object from the family? Dont I need to set up some sort of an extra event which will constantly feed one into the other somewhere along these lines?

It seems to me that is a sort of an ugly solution to something as simple as comparing a variable between two instances of an object.

I am not being lazy here. I simply have no idea how to make your solution work.
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

Post » Sun Jan 12, 2014 8:33 pm

If a family has an instance variable each member of the family has the instance variable. you can adress the member directly, but you can also adress the family. so the variable can be different for each member of the family.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 13, 2014 12:16 am

[QUOTE=LittleStain] If a family has an instance variable each member of the family has the instance variable. you can adress the member directly, but you can also adress the family. so the variable can be different for each member of the family.[/QUOTE]

I tried it on a simpler situation and it works as you said.

But i am a bit confused about this set up still.

To clarify:
Calling an object through the family simply adds the "any" to the condition.
So in your set up its saying
If the picked object is overlapping with any object from that family with a value set to x, then do this to the picked object.

In this case families are extremely useful and what you just showed me makes my life much easier in some of the other things I want to implement.

How does this work on triggering a change in variable level?
If I trigger a change of a variable on a family level - it changes it for all the children?


Much rep to you sir for showing me this!!! Sorry it took me a while to figure out
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, LunaticCat and 7 guests