trampoline_call Synchronous

Call a function while supplying a synthetic call stack and optional execution context. This is for diagnostic or compatibility work that must control what the callback sees as its caller.

Syntax
Luau
trampoline_call(
    callback: Function,
    callstack: {CallFrame},
    options: TrampolineOptions,
    ...args: any
) -> (success: boolean, ...results: any)

Parameters

Function parameters
ParameterTypeDescription
callbackFunctionFunction to call.
callstack{CallFrame}Array of frames with func and integer currentline fields.
optionsTrampolineOptionsTable with optional script, identity, env, and thread context fields.
...argsanyArguments forwarded to the callback.

Argument fields

CallFrame fields
Luau
CallFrame = {func: Function, currentline: number}
TrampolineOptions fields
Luau
TrampolineOptions = {script: Instance?, identity: number?, env: Table?, thread: thread?}

Returns

(success: boolean, ...results: any)

A protected result tuple: success boolean followed by returned values or an error.

Usage notes

The callback must finish without yielding. Frame entries are validated before the call.

Example

Example
Luau
local function caller() end
local ok, result = trampoline_call(
    function(value) return value * 2 end,
    { { func = caller, currentline = 1 } },
    {},
    5
)
print(ok, result) -- true, 10
Kawaii documentation