Commands/function

Runs commands founds in the corresponding function file with command execution context (executor, execution position, angles, etc) of the /function command.

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

Syntax

 * Java Edition


 * Bedrock Edition

Arguments







 * (in  mode)


 * (in  mode)

Output
$$:
 * 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 message displayed in chat returns the number of commands ran (not the number of commands that succeed) plus the number of embedded functions called by a function.
 * The chat output count of is 1(one command in foo:bar3).
 * The chat output count of is 1 (one command in foo:bar2) + 1 (one command in foo:bar3) + 1 (one embedded function) = 3.
 * The chat 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 functions) = 5.
 * If successful, always returns 1. Otherwise, returns 0.
 * If successful, the return value of is the same as chat output count. Otherwise, returns 0.
 * The chat 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 functions) = 5.
 * If successful, always returns 1. Otherwise, returns 0.
 * If successful, the return value of is the same as chat output count. Otherwise, returns 0.

Examples

 * 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:
 * To run a function macro with arguments a=42, b="example":
 * To run a function macro with arguments from storage :
 * To run a function macro with arguments from storage :