Can I set a value with two choices of Random ranges?

I’m wondering if I can set a variable to be a range of
RandomInRange(1, 9) or RandomInRange(20, 29).

Is this possible with some form of OR operator logic?

You want your variable to be a range itself, or you want it to be a value from one of those ranges?

Assuming the latter, you can either:

  • Do Random(1), then if it’s 0, assign a value from the first range, or 1 then assign a value from the second range.

  • Do RandomInRange(1, 29), then if it’s between 10 and 19, do it again (some sort of loop).

There’s probably simpler solutions…

Yes, sorry. I just want it to be a number taken from either of the two different ranges. I’m going with your first suggestion unless I find find out I can use II or something.

What a shame, if the ranges were (1, 9) and (21, 29) you could use

RandomInRange(1, 9) + 20*Random(1)

The second random has 50% chance to be 0 and leave the result in range (1, 9), and 50% chance to be 1 and add 20 shifting to (21, 29).

For your problem, you can do it with two actions, no sub-events needed, first create a random variable:

Do = Random(1) to variable SecondRange

And then use it in the expression:

RandomInRange(1 - Variable(SecondRange), 9) + 20*Variable(SecondRange)

Or just:

(1 -  Variable(SecondRange))*RandomInRange(1, 9) + Variable(SecondRange)*RandomInRange(20, 29)

I had the same thought! :smiley:

Wha! So much maths. But I like it.