How can I count my units with different instance variable...

Get help using Construct 2

Post » Fri Oct 23, 2015 3:29 pm

Hi,

I have one npc type with a "function" instance variable. This variable consist a basic "idle" value. I have six in this npc type.
I can change their instance variable one by one if I want. So, if I change 4 units inst vari instead of idle to woodcutting I remain 2 npc with idle and 4 with woodcutting inst vari.

Now, I want to counting that how many woodcutter units I have at this moment and write in a global variable.
I don't know how should I do this because I need a number to "set global vari", but have no any number except the 6 npc. How can I count how many woodcutters and idle units I have?

I tried this method:

Conditions:
- Every thick
- Pick nth instance >>> Object: NPC >>> Instance: npc.Function = "woodcutting"

Actions:
- Set global variable >>> ??????

Thank you!
B
5
S
1
Posts: 37
Reputation: 441

Post » Fri Oct 23, 2015 3:47 pm

System pick by comparison NPC : NPC.function = woodcutting
> system set Global variable : Npc.pickedcount
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 » Fri Oct 23, 2015 3:48 pm

You can use the PickedCount expression.

NPC.Function = "woodcutting" -> Set global to NPC.PickedCount
else -> Set global to 0
B
74
S
31
G
26
Posts: 999
Reputation: 20,208

Post » Sat Oct 24, 2015 12:43 am

Thanks! The PickedCount was the missing part. The pick by comparison didn't work.

I had to use the "pick by evaluate" It's working correctly now

- pick by evaluate:
Obj: NPC
Expression: NPC.Function = "Woodcutting"

- Set global variable
Npc.PickedCount
B
5
S
1
Posts: 37
Reputation: 441


Return to How do I....?

Who is online

Users browsing this forum: jezjones24, Lancifer, matriax and 19 guests