| 05-19-2005, 03:14 AM | #1 |
I want to have a loop run that randomizes an integer variable to any number between 1-12, except one number, which doesnt really matter, say 5 (chances are low of course, but it cannot be 5 again). I think all I need to know is what the "exitwhen" thing should be. Probably really simple, but I know nothing at all about custom scripts/JASS. |
| 05-19-2005, 04:36 AM | #2 |
um, why do you need a loop in the first place? |
| 05-19-2005, 12:47 PM | #3 |
So you want it to stop when it reaches a given number? I used an If/then set within the loop that used Skip Remaining Actions if the condition was met. It seems to work just fine. |
| 05-19-2005, 07:18 PM | #4 | |
Quote:
um, why not exitwhen (conditional) to exit the loop instead of skip remaining actions, which will skip anything after the loop as well... i still don't understand what is being asked of in the original post though, what are you trying to accomplish? |
| 05-19-2005, 07:39 PM | #5 |
No, the only number it can't be is 5. So if it randomly selects 5 the first time, I want it to random again. But again theres still a chance of 5 being chosen again. So I want it to stop the loop when it is any number 1-12 except 5. |
| 05-19-2005, 07:54 PM | #6 |
Code:
custom script: loop
set randomInteger = random integer number between 1 and 12
custom script: exitwhen (udg_randomInteger != 5)
custom script: endloop |
| 05-20-2005, 06:08 AM | #7 |
you can also go random 1 to 11, and after if > 4 then do (number + 1), foregoing the whole loop process but i guess the chances of getting 5 three times in a row is only 7%, and beyond that only gets much smaller |
