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 preprocessor if statements #108

Open
MysteryBlokHed opened this issue Aug 4, 2021 · 0 comments
Open

Add preprocessor if statements #108

MysteryBlokHed opened this issue Aug 4, 2021 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed preprocessor Related to the preprocessor

Comments

@MysteryBlokHed
Copy link
Owner

MysteryBlokHed commented Aug 4, 2021

Adding something similar to C's #if and #endif directives would make it easier to enable or disable blocks of code. A boolean could be read from the vars.toml file, and then the code contained would only be compiled if the condition is true. Something like this:

!if &enable_cool_feature
    func a_function
        say Hello
    end
!else
    func a_function
        say Hi
    end
!end

With a vars.toml like this:

# Enables a cool feature in the datapack
enable_cool_feature = true

If you have a large project, this could make it easier for users to only enable the parts that they expect to use, meaning less functions come up in the in-game autocomplete and a smaller datapack size.

@MysteryBlokHed MysteryBlokHed added the enhancement New feature or request label Aug 4, 2021
@MysteryBlokHed MysteryBlokHed added this to the Databind 0.7 milestone Aug 7, 2021
@MysteryBlokHed MysteryBlokHed added the preprocessor Related to the preprocessor label Aug 11, 2021
@MysteryBlokHed MysteryBlokHed removed this from the Databind 0.7 milestone Aug 23, 2021
@MysteryBlokHed MysteryBlokHed added the help wanted Extra attention is needed label Aug 25, 2021
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 preprocessor Related to the preprocessor
Projects
None yet
Development

No branches or pull requests

1 participant