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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions extensions/community/RoundToAnyNumber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"author": "",
"category": "General",
"extensionNamespace": "",
"fullName": "Round to any number",
"helpPath": "",
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTTI1LDMxSDdjLTEuMSwwLTItMC45LTItMlYzYzAtMS4xLDAuOS0yLDItMmgxOGMxLjEsMCwyLDAuOSwyLDJ2MjZDMjcsMzAuMSwyNi4xLDMxLDI1LDMxeiIvPg0KPHJlY3QgeD0iOSIgeT0iNSIgY2xhc3M9InN0MCIgd2lkdGg9IjE0IiBoZWlnaHQ9IjQiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjE2IiBjeT0iMTQiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjIyIiBjeT0iMTQiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEwIiBjeT0iMTQiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjE2IiBjeT0iMjAiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjIyIiBjeT0iMjAiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEwIiBjeT0iMjAiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjE2IiBjeT0iMjYiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjIyIiBjeT0iMjYiIHI9IjEiLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEwIiBjeT0iMjYiIHI9IjEiLz4NCjwvc3ZnPg0K",
"name": "RoundToAnyNumber",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Education and Learning/a9c4a6e379367954c8cc89f726a41b7c6e9b31944fb511e27de797fcaafa3ae0_Education and Learning_education_calculator_maths.svg",
"shortDescription": "Allows for easy rounding to any number.",
"version": "1.0.0",
"description": [
"This extension add the ability to round to any number. This allows to round to numbers like 100, 200 or even 2531.",
"",
"This extension works by rounding the first number to the nearest multiple of the second number.",
"For example, rounding 154 to 100 would round it to 200 it's is closer than 100.",
"Rounding 500 to 130 would round it to 520 since it's the closest multiple of 130 (130, 260, 390, 520).",
"",
""
],
"tags": [
"math",
"rounding",
"round to"
],
"authorIds": [
"2zlLuuwKidTQKeeBwNGHOao4URg1"
],
"dependencies": [],
"eventsFunctions": [
{
"description": "Round the specified number to the nearest multiple of the second number.",
"fullName": "Round to any",
"functionType": "Expression",
"name": "RoundTo",
"sentence": "",
"events": [
{
"type": "BuiltinCommonInstructions::Comment",
"color": {
"b": 0,
"g": 0,
"r": 0,
"textB": 255,
"textG": 255,
"textR": 255
},
"comment": "Calculates the rounding based on this formula:\nround(Variable1 / Variable2) * Variable2"
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "SetReturnNumber"
},
"parameters": [
"round(GetArgumentAsNumber(\"RoundNumber\")/GetArgumentAsNumber(\"RoundTo\"))*GetArgumentAsNumber(\"RoundTo\")"
]
}
]
}
],
"expressionType": {
"type": "expression"
},
"parameters": [
{
"description": "The number to be rounded",
"name": "RoundNumber",
"type": "expression"
},
{
"description": "The number to round to",
"name": "RoundTo",
"type": "expression"
}
],
"objectGroups": []
}
],
"eventsBasedBehaviors": [],
"eventsBasedObjects": []
}