Check if a variable is dividable by 3

0 favourites
  • 10 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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?

  • Check the number in the variable like this:

    variable%3=0;

  • 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)

  • Here's an example for you:

    https://dl.dropboxusercontent.com/u/166 ... _by_3.capx

  • Wow!

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

  • Wow!

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

    You're welcome. Good luck to your project.

  • > 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!

  • > 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use event: Is Between Values and use these:

    Value: int(right(str(<your value>),1))

    Lower bound: 0

    Upper bound: 2

  • Use event: Is Between Values and use these:

    Value: int(right(str(<your value>),1))

    Lower bound: 0

    Upper bound: 2

    Awesome!

    Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)