Following the 1.14 update I became interested in creating data packs; however, having only limited experience using the command system within Minecraft, I am finding it hard to locate resources for proper syntax and programming. Namely, calling a child function from a parent. The Minecraft Wiki seems to suggest that it is possible to create a variable and run a function from it ( In the wiki the example used is the foo:bar command which somehow links to the child function ). I understand that in the .mcfunction file each command is run line by line, so if it is indeed possible to create a variable what syntax would one use to separate the space of the function from the rest of the file?
Edit: I just realized that the first line within the example I referenced is the command being run in-game
Edit #2: apparently it is not an in game command, but rather a file calling a separate function, therefore acting as a variable.
execute if [something to check] run function mypack:myfunction
I only recently learned how to write a data pack, but essentially it uses only in-game commands (console / command block usable), but runs them like a script instead of a true function as programming languages would have. You can do more complex tasks and run large numbers of commands quickly. The data pack code is parsed and cached so it can be executed more efficiently, too.
Variables are tricky. You either can set a tag on an entity or use scoreboards. I re-worked Magic Sorting System data pack (https://github.com/isaaclepes/Scientific-Sorting-System), look at the load, init, and tick functions. The tick function adds 1 to a scoreboard value every 1/20th of a second. When that scoreboard value matches N it will execute a function. After it reaches 100, the score is reset to 1 and continues counting up. This allows you to time the execution of your main loops.
I apologize, I didn't realize this was 2019... ignore my necropost
Following the 1.14 update I became interested in creating data packs; however, having only limited experience using the command system within Minecraft, I am finding it hard to locate resources for proper syntax and programming. Namely, calling a child function from a parent. The Minecraft Wiki seems to suggest that it is possible to create a variable and run a function from it ( In the wiki the example used is the foo:bar command which somehow links to the child function ). I understand that in the .mcfunction file each command is run line by line, so if it is indeed possible to create a variable what syntax would one use to separate the space of the function from the rest of the file?
Edit:
I just realized that the first line within the example I referenced is the command being run in-gameEdit #2: apparently it is not an in game command, but rather a file calling a separate function, therefore acting as a variable.
calling a function
execute run function mypack:myfucntion
execute if [something to check] run function mypack:myfunction
I only recently learned how to write a data pack, but essentially it uses only in-game commands (console / command block usable), but runs them like a script instead of a true function as programming languages would have. You can do more complex tasks and run large numbers of commands quickly. The data pack code is parsed and cached so it can be executed more efficiently, too.
Variables are tricky. You either can set a tag on an entity or use scoreboards. I re-worked Magic Sorting System data pack (https://github.com/isaaclepes/Scientific-Sorting-System), look at the load, init, and tick functions. The tick function adds 1 to a scoreboard value every 1/20th of a second. When that scoreboard value matches N it will execute a function. After it reaches 100, the score is reset to 1 and continues counting up. This allows you to time the execution of your main loops.
I apologize, I didn't realize this was 2019... ignore my necropost