how to toggle a higher number?

BrynjeBamsenBrynjeBamsen Member Posts: 188
edited November -1 in Working with GS (Mac)
i know how to toggle between 0-1 and so on.

game.howmany to (gamehowmany+1)%2

but if i want to toggle betweem 6 and 7

how would go about doing that??

Comments

  • InLikeFlynnInLikeFlynn Member Posts: 171
    % will tell you the remainder after dividing by that number. So 201%100 is 1, because 100 fits into 200 twice, with 1 as the remainder. With 6 and 7, you could put

    game.howmany to ((game.howmany+1)%2)+6

    does that help?
  • BrynjeBamsenBrynjeBamsen Member Posts: 188
    Sorry it did not work.... Any other way of doing it
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    is there a reason it has to be 6 and 7, why not just use 1 and 2?
  • BrynjeBamsenBrynjeBamsen Member Posts: 188
    Yes... 1-2 is a possibility... Only option it cant be is 0-1
  • BrynjeBamsenBrynjeBamsen Member Posts: 188
    is it really that hard to toggle between 1-2 instead of 0-1

    Cant wrap my head around it... pleeease help a brother out!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    sorry thats what i meant is there a reason it cant be 0-1? if its because the 0-1 is used by a different action, it would be easier to just create a different attribute. It seems like your trying to get multiple modulo out of one attribute but im not to sure. Enlighten me :)
  • BrynjeBamsenBrynjeBamsen Member Posts: 188
    made a work around the works fine.

    game.toggle to (game.toggle+1)%2

    if game.toggle = 0

    Change atribute game.howmany = 1
    otherswise
    Change attribute game.howmany = 2
  • synthesissynthesis Member Posts: 1,693
    This might work for a 6 and 7 toggled value:

    game.toggle = ((game.toggle - 5)%2)+6

    You need to subtract the fixed distance between your value to get to a 0 and 1 toggle base and then re-add the distance value back to it to adjust the 0/1 result back to a 6/7 level.
  • InLikeFlynnInLikeFlynn Member Posts: 171
    If you add or subtract any odd value, then %2 before adding 6 it should toggle. I just tried it out.

    Since you're using rules anyway you can cut out any use of mod and just say

    if toggle = 6
    change attrib toggle to 7
    Otherwise
    change attrib toggle to 6

    Just make sure you use otherwise and not 2 separate rules.
Sign In or Register to comment.