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

Function macro syntax #1696

Closed
Darukshock opened this issue Dec 29, 2024 · 1 comment
Closed

Function macro syntax #1696

Darukshock opened this issue Dec 29, 2024 · 1 comment

Comments

@Darukshock
Copy link

Darukshock commented Dec 29, 2024

[Feature Request]
Hi,
I thought it could be handy having autocompletion & syntax checking when calling a function with inline macro.
Example:
Let's say I have the function:

#> player_motion:internal/summon/crystal
$execute if score $n_full_exp player_motion.internal.math matches 1.. anchored eyes positioned ^ ^ ^$(full_d) run function player_motion:internal/summon/loop
$execute anchored eyes positioned ^ ^ ^$(d) summon end_crystal run damage @s 0

And this mcdoc snippet in my workspace:

/// Setup for spawning crystals
dispatch mcdoc:function["player_motion:internal/summon/crystal"] to struct{
    /// distance from crystal
    d: float,
    /// distance from conditional crystals
    full_d: float
}

The idea is that we would get error warning in those scenarios:

  1. function player_motion:internal/summon/crystal {d:4.0} -> missing argument full_d
  2. function player_motion:internal/summon/crystal {d:{foo:"bar"},full_d:3.0} -> expected a float (hovering over {foo:"bar"})
    Also, when hovering over either d or full_d, we would see the comments written above in the mcdoc, just like how mcdoc currently works.

In conclusion, this would be a really nice tool to:

  1. Prevent misspelling mistakes when calling our own functions
  2. Enhance librairies that have API functions called with macros, so that users can be certain they put the right macro arguments
  3. Accelerate developpement process thanks to autocompletion.
@misode
Copy link
Member

misode commented Dec 30, 2024

We have something similar planned in #1070

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants