Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RandomRangewithGap #1305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

RandomRangewithGap #1305

wants to merge 1 commit into from

Conversation

github-actions[bot]
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ New extension A new extension
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

2 participants