MysteryBlokHed / databind

Expand the functionality of Minecraft Datapacks.
https://databind.rtfd.io/en/stable
GNU General Public License v3.0
4 stars 0 forks source link

Add for loops with `vars.toml` #117

Open MysteryBlokHed opened 3 years ago

MysteryBlokHed commented 3 years ago

Adding preprocessor for loops (sort of like if/else statements in #108) that iterate over values from the vars.toml file would mean an easier way of customizing some aspects of a datapack. For example, if you wanted users to be able to provide a list of commands, then add something before each of those, you could have a vars.toml file like this:

commands = [
    "say Hello, World!",
    "say Example",
]

And code like this:

!for $cmd in commands
    execute if tvar run_something matches 1 run $cmd
!end

Which would compile to:

execute if tvar run_something matches 1 run say Hello, World!
execute if tvar run_something matches 1 run say Example