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

Add arguments to methods #126

Open
Melon-The-Dev opened this issue Jul 9, 2024 · 3 comments
Open

Add arguments to methods #126

Melon-The-Dev opened this issue Jul 9, 2024 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Melon-The-Dev
Copy link

Melon-The-Dev commented Jul 9, 2024

Spec

Add a new mini editor dialog for defining a method, similar to the current one for defining variables. The dialog should let the user set:

  • A method name
  • An arbitrary list of method arguments, each with a name and a type (String, Number, Vector2, etc)

When defined, the method definition is stored in the Block Coding resource, like current variables definitions.

After defined, the Block Picker should be refreshed and present the defined methods as blocks under category "Communication | Methods". One "Define FOO" block and one "Call FOO" block (where "FOO" is the method name).

  • "Define FOO" should have arguments that can be dragged to the snapped blocks below. See block "when this node collides with (something)" for reference.
  • "Call FOO" should have input slots for each argument. And each input slot should only accept the corresponding type.

Note that this is for defining/calling methods in the same Block Coding node. Not for passing arguments to methods defined in other Block Coding nodes.

Original report below:

What Happened

im trying to call a method with arguments but there are no inputs to put the argument values..

after some digging on the code i wanted to add it myself, but i got stuck cuz idk what to put as the type on the block format, it could be just VARIANT or something but idk for sure

@manuq
Copy link
Contributor

manuq commented Jul 10, 2024

@Melon-The-Dev thanks. Yes this is something we need to think about. I am researching how to enhace blocks with overloading. For instance, the current Print block only takes a String, but it should be able to take any Variant as argument.

@Melon-The-Dev
Copy link
Author

@Melon-The-Dev thanks. Yes this is something we need to think about. I am researching how to enhace blocks with overloading. For instance, the current Print block only takes a String, but it should be able to take any Variant as argument.

ahh i see, i might tinker around the code of the addon and see if i can do smth

@dylanmccall dylanmccall added enhancement New feature or request help wanted Extra attention is needed labels Aug 24, 2024
@manuq
Copy link
Contributor

manuq commented Oct 18, 2024

Here is a reference for someone wanting to implement this: https://youtu.be/FARjoscK0vw?t=1650 . That video shows how a function can be defined with arguments in MakeCode Arcade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants