Hi there. Started using scratch eariler today and now i stumbeled opon a probelm. I need to use "Pick random 1 - 10" but i need to get a random number thats NOT one of the 2 latest pick random numbers. Got it to work with latest but now i cant seem to get it to the 2nd latest. Anyone got any idea on how to fix this?
Offline
<when green flag clicked>
<repeat( <set{ }to( <pick random( )to(
[add __ to Latest Numbers}
<end>
<change{ }by(
<if>Latest numbers contains ___
<set{ }to(
<else>
<end>
Offline
You could have two variables ("previous" and "second previous", or whatever you want) and use a repeat until loop to repeatedly choose a random number until it equals neither of them. Then "bump" them down like this:
Repeat until not< <choice = previous> or <choice = second_previous> > set choice to pick random 1 to 10 EndRepeat set second_previous to previous set previous to choice
If that makes sense, great. If it doesn't, I can blockify it for you.
Offline