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

New extension: Round to any number #1271

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

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented May 4, 2024

Description

This extension adds the ability to round to any number. Useful for things like a grid system.

How to use the extension

The extension is used through a function RoundToAnyNumber::RoundTo() where the first number is the number to be rounded and the second number is the number to round to.
It works based on this formula: round(Number1 / Number2) * Number2

Examples:
Rounding 12345 to 100 will give 12300.
Rounding 720 to 300 will give 600.
Rounding 7382.8129 to 0.29 will give 7 382.82 (which is a multiple of 0.29).

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

Round to any number example.zip

Extension file

RoundToAnyNumber.zip

@github-actions github-actions bot requested a review from a team as a code owner May 4, 2024 09:56
@github-actions github-actions bot added the ✨ New extension A new extension label May 4, 2024
@github-actions github-actions bot added this to Needs review in Extensions review May 4, 2024
@github-actions github-actions bot mentioned this pull request May 4, 2024
3 tasks
@D8H
Copy link
Contributor

D8H commented May 4, 2024

Thank you for submitting an extension.

What do you think about adding this expression to the rectangular grid extension?

The parameters could be: "Cell size" and "Grid offset" and the expression could be used in the snap action to avoid the formula duplication.

@D8H D8H moved this from Needs review to Needs changes in Extensions review May 4, 2024
@NiQsterVX
Copy link

I could add it but I have a feeling that limiting this to just that extension would feel like a bit of a waste since it is a very general tool.

@D8H
Copy link
Contributor

D8H commented May 5, 2024

I could add it but I have a feeling that limiting this to just that extension would feel like a bit of a waste since it is a very general tool.

Do you fear that people won't find it?
It's true that having a lot of features in one extension can make the features harder to find but the opposite is also true.
I think that these 2 features are very similar and it makes sense to have them in the same extension.

@NiQsterVX
Copy link

Don't get me wrong, I like the idea of integrating this into other extensions but using it for only one purpose while it's a very general tool feels limiting.

@D8H
Copy link
Contributor

D8H commented May 6, 2024

but using it for only one purpose while it's a very general tool feels limiting.

I didn't mean to hide the expression, users can still use it.
What do you mean by "only one purpose"?

@tristanbob
Copy link
Contributor

Another idea is to add the expression to this extension:

https://wiki.gdevelop.io/gdevelop5/extensions/extended-math/

@D8H
Copy link
Contributor

D8H commented May 6, 2024

Another idea is to add the expression to this extension:

https://wiki.gdevelop.io/gdevelop5/extensions/extended-math/

This is not a common math function. I doubt people will try to search this feature in a Math extension.

@NiQsterVX
Copy link

NiQsterVX commented May 6, 2024

I didn't mean to hide the expression, users can still use it. What do you mean by "only one purpose"?

Only one purpose meaning it can only be used for that extension (snap to grid) and thus limiting it to only one use - snapping

@D8H
Copy link
Contributor

D8H commented May 6, 2024

I didn't mean to hide the expression, users can still use it. What do you mean by "only one purpose"?

Only one purpose meaning it can only be used for that extension (snap to grid) and thus limiting it to only one use - snapping

No matter the extension name, users can use the expression all the same. I don't understand your point.
What is the difference between: RoundToAnyNumber::RoundTo(123, 64) and SnapToGrid::RoundTo(123, 64)?

@NiQsterVX
Copy link

I didn't mean to hide the expression, users can still use it. What do you mean by "only one purpose"?

Only one purpose meaning it can only be used for that extension (snap to grid) and thus limiting it to only one use - snapping

No matter the extension name, users can use the expression all the same. I don't understand your point. What is the difference between: RoundToAnyNumber::RoundTo(123, 64) and SnapToGrid::RoundTo(123, 64)?

Oh

@4ian
Copy link
Collaborator

4ian commented May 6, 2024

The question is: where someones searching for this is the most likely to search in the first place?

@NiQsterVX
Copy link

The question is: where someones searching for this is the most likely to search in the first place?

When i was trying to find if there was any extension for this before making it, i searched for "round" "round to any" "custom rounding" and similar.
I feel like integrating it to a math extension would be good to not make a standalone extension just for rounding.

@D8H
Copy link
Contributor

D8H commented May 7, 2024

Considering that there are roundTo, floorTo and ceilTo that work with power of 10 in GDevelop and a ToFixedString in the math extension to format exact decimal values, I guess people will use the new one only for writing formula around snapping (with a size and offset).

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
Extensions review
  
Needs changes
Development

Successfully merging this pull request may close these issues.

None yet

4 participants