Skip to content

API reference / @jsprismarine/prismarine / command/function/runtime

command/function/runtime ​

Classes ​

Interfaces ​

FunctionRunOutcome ​

Defined in: packages/prismarine/src/command/function/runtime.ts:49

What one call did, which is what /function and execute if function read, plus the line count a tick reports.

Extends ​

Properties ​

commands ​

readonly commands: number

Defined in: packages/prismarine/src/command/function/runtime.ts:55

How many command lines reached the dispatcher. The same as result for a function that never reached a /return, and the honest number for one that did.

matched ​

readonly matched: boolean

Defined in: packages/commands/src/host.ts:576

Whether any function the call ran returned a non-zero value through /return. A tag matches when any of its members did, which is why this is not result !== 0: members returning 1 and -1 sum to 0 and still match.

Inherited from ​

FunctionOutcome.matched

result ​

readonly result: number

Defined in: packages/commands/src/host.ts:569

What /function reports and execute store result captures: the sum of the values /return produced, or the number of command lines that ran when nothing the call reached returned a value.

Inherited from ​

FunctionOutcome.result


FunctionRuntimeOptions ​

Defined in: packages/prismarine/src/command/function/runtime.ts:59

How to build a FunctionRuntime.

Properties ​

dispatch ​

readonly dispatch: (commandLine, source) => CommandOutcome

Defined in: packages/prismarine/src/command/function/runtime.ts:68

Runs one command line against a source, which is the server's vanilla dispatcher. Injected rather than imported so the runtime is testable without a dispatcher, and so nothing here depends on how a dispatch reports its results.

Parameters ​
commandLine ​

string

source ​

CommandSource

Returns ​

CommandOutcome

limits? ​

readonly optional limits?: Partial<ExecutionLimits>

Defined in: packages/prismarine/src/command/function/runtime.ts:72

Overrides the two gamerule limits; see DEFAULT_EXECUTION_LIMITS.

loaded ​

readonly loaded: ServerFunctions

Defined in: packages/prismarine/src/command/function/runtime.ts:61

The functions and tags the pack stack holds; see loadServerFunctions.

report ​

readonly report: (diagnostic) => void

Defined in: packages/prismarine/src/command/function/runtime.ts:70

Where a diagnostic goes. The server sends these to its log.

Parameters ​
diagnostic ​

Diagnostic

Returns ​

void

Variables ​

MAX_NESTED_FUNCTION_DISPATCH ​

const MAX_NESTED_FUNCTION_DISPATCH: 64 = 64

Defined in: packages/prismarine/src/command/function/runtime.ts:40

How deep a /function may nest when the nesting goes back through the dispatcher rather than through the executor's own queue.

A function line inside a function is control flow the executor reads itself, so it stays on the executor's heap-allocated frame stack and is bounded by maxCommandSequenceLength. execute ... run function is not: it is a command, so it re-enters this runtime through a command body and each level costs real JavaScript stack. Java has no such split, because its ExecutionContext carries both, so this cap exists only to keep a mutually recursive pack from overflowing the host stack before the operation limit can stop it.