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

Allow nullables and params arrays in console commands #505

Merged
merged 2 commits into from
Dec 2, 2023

Conversation

Govorunb
Copy link
Contributor

Changes made in this pull request

Console commands

  • Allow using nullable value types in parameters
    • A command like ToggleSomething(bool? enable = null) can now be registered and can e.g. print the current status of the toggle if called with no arguments
  • Allow using a params T[] parameter to consume the rest of the input
    • This allows commands to parse an arbitrary number of (still primitively-typed) parameters
    • Something simple like a command that repeats your input back at you is now extremely easy to define
    • It only makes sense to have one params array and only as the last parameter - which is enforced by the compiler

Breaking changes

  • No breaking changes to existing commands from my testing

Copy link
Contributor

github-actions bot commented Nov 24, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Govorunb
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Nov 24, 2023
Copy link
Contributor

@Alexejhero Alexejhero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dg0AnDCW0AA741R

Clarify parameter parsing error message
Copy link
Member

@LeeTwentyThree LeeTwentyThree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful, I also appreciate the friendly type names 👍

@LeeTwentyThree LeeTwentyThree merged commit 0d038fd into SubnauticaModding:master Dec 2, 2023
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants