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

bind command #31

Closed
longuint opened this issue Jun 8, 2024 · 5 comments
Closed

bind command #31

longuint opened this issue Jun 8, 2024 · 5 comments

Comments

@longuint
Copy link
Contributor

longuint commented Jun 8, 2024

I don't know if this is implementable in the current version of commander but I would love to have to option to bind UserInputService / Mouse events to commands. For example tf2 and a lot of source games have the syntax:
bind KEY "command"
I think this would add a lot of customizability, and allow users to tailor build commander around their experience.

@longuint
Copy link
Contributor Author

longuint commented Jun 8, 2024

After further deliberation, instead of a built-in command. There should be a decorator with a key combination.
This decorator's key combination should be similar to react-pretty-hooks's useKeyPress() function.

@Commander()
export ExampleBindableCommand {
    @Command()
    @Shortcut("LeftAlt+E")
    run(ctx: CommandContext) {}
}

The type for the shortcut could probably just be imported from react-pretty-hooks, KeyCodes.

A better way could probably be deliberated because I know the luau package is planned.

@sasial-dev
Copy link
Contributor

Instead of a string, the shortcut could be Array<Enum.KeyCode | Enum.KeyCode[]>
This would allow for @Shortcut([Enum.KeyCode.F4]) and mutiple keys such as @Shortcut([[Enum.KeyCode.LeftAlt, Enum.KeyCode.E]]).
And combined: @Shortcut([Enum.KeyCode.F4, [Enum.KeyCode.LeftAlt, Enum.KeyCode.E]])

@longuint
Copy link
Contributor Author

longuint commented Jun 9, 2024

You make an excellent point there, it would be easier to test and stub if the type builds of an array.

@paradoxuum
Copy link
Owner

paradoxuum commented Jun 9, 2024

I think it might be better to have this as an option passed to @Command rather than a separate decorator, since commands are synced to the client as Map<string, CommandOptions>.

@longuint
Copy link
Contributor Author

longuint commented Jun 9, 2024

I am writing a pull request at the moment, it's using the shortcut as an option on the CommandOptions interface.

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

No branches or pull requests

3 participants