API reference / @jsprismarine/mcfunction / CompiledFunction
Class: CompiledFunction
Defined in: compile.ts:41
A function file ready to run. Instances come from compileFunction and are shared by every call, including the macro cache.
Constructors
Constructor
new CompiledFunction(
id,lines):CompiledFunction
Defined in: compile.ts:52
Parameters
id
string
The namespaced id the function is registered under.
lines
readonly CompiledLine[]
Returns
CompiledFunction
Properties
id
readonlyid:string
Defined in: compile.ts:54
The namespaced id the function is registered under.
macro
readonlymacro:boolean
Defined in: compile.ts:43
Whether any line of the function is a macro line, so calls need arguments.
variables
readonlyvariables: readonlystring[]
Defined in: compile.ts:46
Every variable the function substitutes, once each, in first-use order.
Accessors
cachedArgumentSets
Get Signature
get cachedArgumentSets():
number
Defined in: compile.ts:134
How many argument sets the macro cache currently holds.
Returns
number
length
Get Signature
get length():
number
Defined in: compile.ts:72
How many commands the function declares.
Returns
number
Methods
instantiate()
instantiate(
args?):InstantiationResult
Defined in: compile.ts:85
Produces the commands one call runs.
A plain function ignores the arguments, the way the Java server silently ignores a compound passed to a non-macro function. A macro function needs one entry per variable it substitutes and reports the first entry it is missing; the Java server skips the whole call in that case, and so does FunctionExecutor.
Parameters
args?
Readonly<Record<string, unknown>>