Commands/function

Runs a function or all functions in a tag from a datapack. Runs a function from a behavior pack.

Arguments

 * function


 * Java Edition
 * May be of the format, or.
 * The format without the  prefix, , runs a single function located at.
 * The format with the  prefix, , runs all functions included in the function tag located at.


 * Bedrock Edition
 * May be of the format
 * Runs the function located at

Result

 * Fails if the argument is not specified correctly.


 * If successful, runs a function through the command source which ran the command.


 * Java Edition
 * Success count is the sum of success counts of all commands ran in the function/functions plus 1 (this command itself).
 * For example,
 * foo:bar1
 * foo:bar2
 * foo:bar3
 * The Success count of is 1 (one command in foo:bar3) + 1 (this command itself) = 2.
 * The Success count of is 2 (from above) + 1 (this command itself) = 3.
 * The Success count of is 3 (from above) + 1 (this command itself) = 4.
 * Output of the command returns the number of commands ran (not the number of commands that succeed) plus the number of embedded functions called by a function.
 * The output count of is 1(one command in foo:bar3).
 * The output count of is 1 (one command in foo:bar2) + 1 (one command in foo:bar3) + 1 (one embedded function) = 3.
 * The output count of is 1 (one command in foo:bar1) + 1 (one command in foo:bar2) + 1  (one command in foo:bar3) + 2 (two embedded function) = 5.
 * If successful, always returns 1. Otherwise, returns 0.
 * If successful, the return value of is the same as output count. Otherwise, returns 0.
 * The output count of is 1 (one command in foo:bar1) + 1 (one command in foo:bar2) + 1  (one command in foo:bar3) + 2 (two embedded function) = 5.
 * If successful, always returns 1. Otherwise, returns 0.
 * If successful, the return value of is the same as output count. Otherwise, returns 0.

Examples

 * Java Edition
 * To run a function located at  in a loaded data pack:
 * To run all functions in a function tag located at :
 * To run a function if there is a sheep within a radius of 2 blocks:
 * To run a function unless the executor is a player: