Check if a variable is dividable by 3

Discussion and feedback on Construct 2

Post » Fri Oct 14, 2016 1:29 pm

Hey guys,

I got a math related question:
I have a variable witch keeps track of how many times the player goes to the main menu. I want to check if it is dividable by 3 and then do something like show an ad.

How can I achieve this?
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518

Post » Fri Oct 14, 2016 1:45 pm

Check the number in the variable like this:
variable%3=0;
B
135
S
33
G
17
Posts: 1,557
Reputation: 20,717

Post » Fri Oct 14, 2016 2:22 pm

glerikud wrote:Check the number in the variable like this:
variable%3=0;


Hey,

It does not seem to work.
I made it so whenever I clicked it would ad 1 point to the var, I added a debug txt object witch would show me the var points and I added your code like this:

System - Compare Variable - [Var Name] % 3 = 0 (And then I would change the position of an object)
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518

Post » Fri Oct 14, 2016 3:38 pm

B
135
S
33
G
17
Posts: 1,557
Reputation: 20,717

Post » Fri Oct 14, 2016 8:11 pm

Wow!
I didn't know you could compare two values! This helped me a lot, thanks!
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518

Post » Sat Oct 15, 2016 10:35 am

TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.
B
135
S
33
G
17
Posts: 1,557
Reputation: 20,717

Post » Sat Oct 15, 2016 8:53 pm

glerikud wrote:
TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.


<3 You to!
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518

Post » Wed Oct 19, 2016 5:15 pm

glerikud wrote:
TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.


Hi again,

I got another related question (if you don't mind...):
how would I do the same thing with a variable that would jump by 1,2 or 3 at a time?
I basically want this:
"If var X is equal to 10 or 11 or 12 then execute code"
I want it to happen every 10 units (10 or 11 or 12; 20 or 21 or 22... and so on) and the var would also go indefinitely (so I can't hard-code it)
Do you have any idea how to do this?

Also, if you don't have the time to help me with this I will start a new entry in the forum; I replied back because you knew already what I wanted and it is easier to explain =D
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518

Post » Wed Oct 19, 2016 6:44 pm

Use event: Is Between Values and use these:

Value: int(right(str(<your value>),1))
Lower bound: 0
Upper bound: 2
Image
B
30
S
9
G
3
Posts: 171
Reputation: 3,329

Post » Wed Oct 19, 2016 8:09 pm

gameglaux wrote:Use event: Is Between Values and use these:

Value: int(right(str(<your value>),1))
Lower bound: 0
Upper bound: 2


Awesome!
Thank you!
ImageImageImageImage
B
28
S
9
G
7
Posts: 229
Reputation: 5,518


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests