Skip to content

RandomRangewithGap#1305

Open
github-actions[bot] wants to merge 1 commit intomainfrom
extension/djsedaw/1302
Open

RandomRangewithGap#1305
github-actions[bot] wants to merge 1 commit intomainfrom
extension/djsedaw/1302

Conversation

@github-actions
Copy link
Contributor

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

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • 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

RandomRangewithGapexample.zip

Extension file

RandomRangewithGap.zip

@github-actions github-actions bot requested a review from a team as a code owner May 31, 2024 17:14
@github-actions github-actions bot added the ✨ New extension A new extension label May 31, 2024
@github-actions github-actions bot mentioned this pull request May 31, 2024
3 tasks
@D8H
Copy link
Contributor

D8H commented May 31, 2024

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:

@djsedaw
Copy link

djsedaw commented Jun 1, 2024

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

@D8H D8H added the ⌨ JavaScript Uses JavaScript code, and thereby needs a reviewer who knows JavaScript. label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⌨ JavaScript Uses JavaScript code, and thereby needs a reviewer who knows JavaScript. ✨ New extension A new extension

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

2 participants