Return a value from within a range of values but not the existing value
Slayre77
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
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
@tatiang Thank you once again! ^^ . Honestly, what would I do without your help haha