Looping ints. ?

As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

Hey guys,

I'm trying to create a loop for when button pressed increase my integer game attribute, (which starts at 1) by +1. And then when it hits 8, loop back to 1. Hope this makes sense...

The problem I'm having is it is skipping over the even numbered integers :| ... It is only looping 1,3,5,7,1,3,5,7 etc. How do I loop all integers even and odd from 1 - 8?

Check out my screen shot below :#

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You have:

    (mod(game.MissionsPG+1,8)+1)

    This adds one to the value, then finds the remainder when divided by 8 and then adds one to that. So if your attribute had the value 4, that expression would add 1 to make it 5, find the remainder which is 5, and then add one which is 6. So you've started with 4 and ended up with 6.

    Try this instead:

    mod(game.MissionsPG,8)+1

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @tatiang Thank you!! You're always there with a quick response and the correct answer. Works perfect :)

Sign In or Register to comment.