Each jump of 10, do the same action??

Get help using Construct 2

Post » Fri Aug 23, 2013 4:35 pm

Hello everyone! I have a problem to do the following:
I made a global variable that adds 1 for each second, now the problem is how to make for each jump of 10 , do "action A"? like if the variable is 10 do "action A" and if 20 do action "A again", and 30 and so on.. how do i make it? I need this for a game i'm making to make the Tamagotchi animal feel hungry again every jump of the number I choose depends on this global variable..
shadowfan332013-08-23 16:37:33
B
4
S
1
Posts: 16
Reputation: 507

Post » Fri Aug 23, 2013 4:45 pm

It would probably be a lot easier to give your "tamagochi" a timer-behaviour and call an action on timer end.
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 Aug 23, 2013 4:50 pm

If you want to do it your way you could set up an action:

system compare two values - Globaltime%10 = 0 - (insert action)
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 Aug 23, 2013 4:58 pm

Thanks! It worked :)
B
4
S
1
Posts: 16
Reputation: 507

Post » Fri Aug 23, 2013 7:08 pm

You can also use the modulo (%). This will get the remainder after a division between 2 values. So if value % 10 = 0, that means it is divisible by 10.
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Fri Aug 23, 2013 7:29 pm

Why didn't I think of that @EncryptedCow ?

Oh, right, I did!LittleStain2013-08-23 19:30:46
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 Aug 23, 2013 7:32 pm

@LittleStain ......... I didn't even see that comment somehow. I think I need to get my eyes checked.
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Fri Aug 23, 2013 8:23 pm

No problem @encryptedcow ! :-)
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


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests