GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

knight55knight55 Posts: 5Member
edited June 26 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 Posts: 1,197Key Master, Head Chef, Executive Chef, Member, PRO GameSalad Employee

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

  • knight55knight55 Posts: 5Member

    @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 Posts: 1,197Key Master, Head Chef, Executive Chef, Member, PRO GameSalad Employee

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

    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 Posts: 5Member

    @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 Posts: 5Member

    @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 Posts: 2,797Member, Sous Chef, PRO

    It looks like this:

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

    Here is an example:

  • knight55knight55 Posts: 5Member

    @RThurman said:
    Here is an example:

    Thanks for your help

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

    You are welcome!

Sign In or Register to comment.