How do I do something every Nth time?

From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Hi!

    I have two global numbers (a, b) and i want to add "b" 1 when "a" equals to 10, 20, 30, 40, 50, 60, ...etc. How to do that?

  • You could simply use the System-Compare two values condition.

    First value would be Global variable "a", and compare values would be "10|20|30|40..." etc then set Action to add 1 to Global 'b'.

    For more info on Expressions, see https://www.scirra.com/manual/78/expressions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could simply use the System-Compare two values condition.

    First value would be Global variable "a", and compare values would be "10|20|30|40..." etc then set Action to add 1 to Global 'b'.

    Yes, it would be simple, but I still want to add 1 to "b" when "a" is 18965484848321850. It's impossible to do it by the way you said because number "a" has no limits. So i hope there's an easier way to do it.

  • What does "a" represent?

    If you are saying that "a" could be any unknown numerical value, then without some kind of algorithm or boundary, it will be impossible to test.

  • First you have to understand when you want to check the b's value; my guess is that you will check it when b changes value, so in that event you can put the comparing.

  • Hi see if this helps

  • To make things clear: I have a sprite. When It's clicked its gonna add 1 to "a". I want to make when "a" reaches 10, 20, 30, 40, 50, 60, 70 and so on to add 1 to "b". Like this:

    a=10 b=1

    a=340 b=34

    a=555 b=55

    a=29 b=2

  • To make things clear: I have a sprite. When It's clicked its gonna add 1 to "a". I want to make when "a" reaches 10, 20, 30, 40, 50, 60, 70 and so on to add 1 to "b". Like this:

    a=10 b=1

    a=340 b=34

    a=555 b=55

    a=29 b=2

    Try "On sprite clicked" > "Add 1 to value "a"" & "Set value "b" to (floor(a/10))".

    see my example: [attachment=0:38hjnqb2][/attachment:38hjnqb2]

  • > To make things clear: I have a sprite. When It's clicked its gonna add 1 to "a". I want to make when "a" reaches 10, 20, 30, 40, 50, 60, 70 and so on to add 1 to "b". Like this:

    > a=10 b=1

    > a=340 b=34

    > a=555 b=55

    > a=29 b=2

    >

    Try "On sprite clicked" > "Add 1 to value "a"" & "Set value "b" to (floor(a/10))".

    see my example: [attachment=0:74y1j61i][/attachment:74y1j61i]

    Thanks It works now!!!

  • Thanks It works now!!!

    You're welcome! I saw screenshot of your event sheet, better use sprite font instead of text object, using text objects can kill performance.

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