If, in a .mcfunction file, you want to execute multiple commands depending on some condition, the following is required:
execute if <condition> run function namespace:some_function
# Function namespace:some_function
say Hello world!
give @s minecraft:diamond 64
Note that this requires two .mcfunction files. In most traditional programming languages, however, the following would be possible
if (<condition>) {
<statement>
}
I propose adding a similar syntax to .mcfunction files, allowing for in-line functions, making situations such as conditional statements or executing several commands as/at a group of entities significantly easier and more concise.
execute if <condition> run function {
say Hello world!
give @s minecraft:diamond 64
}
execute as @e[type=minecraft:cow] at @s run function {
data modify entity @s Motion[1] set value 5.0f
particle minecraft:cloud ~ ~ ~ 0 0 0 0.1 10 normal
}
There are already user-made transpilers and variations of the mcfunction language allowing for in-line functions, thus proving that there is indeed a part of the community that would be interested in such a change, and natively supporting this within .mcfunction files would make life for a lot of datapack developers a lot easier.
Please sign in to leave a comment.
1 Comments