Return a value from within a range of values but not the existing value

Slayre77Slayre77 Member, PRO Posts: 115

Hi, I have this question.
For example, attribute X will be set to 1,2 or 3 every second. If the same number is randomed twice, then change X to one of the other 2 values. If this is not possible, at least change for e.g. If 1 is repeated, change to 2; if 2 is repeated, change to 3;if 3 is repeated, change to 1. I've tried (4-attribute.X) but then if X is 2, 4-2=2 so it didn't work. Any help is appreciated, thanks!

Comments

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

    Haven't tested this but I think it would work:

    Change attribute game.X to random(1,3)
    Timer every 1 second
    When attribute game.X=1
    Change attribute game.X to random(1,2)+1
    Otherwise
    When attribute game.X=2
    Change attribute game.X to random(1,2)*2-1
    Otherwise
    When attribute game.X=3
    Change attribute game.X to random(1,2)

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

  • Slayre77Slayre77 Member, PRO Posts: 115

    @tatiang‌ Thank you once again! ^^ . Honestly, what would I do without your help haha :#

Sign In or Register to comment.