RandomRangewithGap
Description
Gdevelop function to pick a random number in the range Min to Max and Specifi a gap of MinGap to MaxGap
Enter: Min value, Max Value, MinGap, MaxGap as direct values or Variables.
How to use the extension
"YourVariable"=RandomRangewithGap::RndRanwGap(Variable(yourmin), Variable(Yourmax), Variable(YourminGap), Variable(YourmaxGap)).
So for Example "YourVariable"=RandomRangewithGap::RndRanwGap(1,10,6,8) will pick a random number between 1 and 10 but exclude numbers between 6 and 8.
Checklist
- [X] I've followed all of the best practices.
- [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
Extension file
Thank you for submitting an extension.
Extensions should only use JavaScript in last resort.
I guess you can generate a random number between min and max - (gapMax - gapMin) and if the value is greater than gapMin, add gapMax - gapMin.
This also works with decimal numbers. For integers, you may have to add 1 if bounds are excluding or including.
Related forum topic:
- https://forum.gdevelop.io/t/new-random-expression-getrandomnumberwithgap/57635
That's a great idea without using the magic JavaScript, have got it working but it will still include the MinGap in the range, MaxGap is fine