How to increment an attribute by 1 everytime another attribute increments by 2

knight55knight55 Member Posts: 5
edited June 2018 in Working with GS (PC)

I have an attribute that increases by 1 as a result from an action in my game and I want another attribute to increase by 1 everytime the first attribute increases twice(that is multiples of 2).

Comments

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,034

    the pseudocode would be:
    if (mod(firstAttribute, 2) == 0) then incrementSecondAttribute,
    if that makes sense

  • knight55knight55 Member Posts: 5

    @adent42 said:
    the pseudocode would be:
    if (mod(firstAttribute, 2) == 0) then incrementSecondAttribute,
    if that makes sense

    I'm not quite sure how to input this in a rule

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,034

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Another fun way to do this would be:

    When round(firstAttribute/2)*2 == firstAttribute then increment secondAttribute

    This basically checks to see if firstAttribute is even before it modifies secondAttribute.

  • knight55knight55 Member Posts: 5

    @adent42 said:

    This doesn't seem to be working for me. It keeps on incrementing the second attribute by 2.
    Could it be because I used the "Index" data type for my attributes

  • knight55knight55 Member Posts: 5

    @RThurman said:
    Another fun way to do this would be:

    When round(firstAttribute/2)*2 == firstAttribute then increment secondAttribute

    This basically checks to see if firstAttribute is even before it modifies secondAttribute.

    Am I meant to type "==" in the expression editor

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    It looks like this:

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Here is an example:

  • knight55knight55 Member Posts: 5

    @RThurman said:
    Here is an example:

    Thanks for your help

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    You are welcome!

Sign In or Register to comment.