Ask here your questions to get help using GDevelop.
User avatar
By BWPanda
#69979 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...
User avatar
By Lizard-13
#70010 What a shame, if the ranges were (1, 9) and (21, 29) you could use
Code: Select allRandomInRange(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:
Code: Select allDo = Random(1) to variable SecondRange

And then use it in the expression:
Code: Select allRandomInRange(1 - Variable(SecondRange), 9) + 20*Variable(SecondRange)

Or just:
Code: Select all(1 -  Variable(SecondRange))*RandomInRange(1, 9) + Variable(SecondRange)*RandomInRange(20, 29)