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.
Luau
trampoline_call(
callback: Function,
callstack: {CallFrame},
options: TrampolineOptions,
...args: any
) -> (success: boolean, ...results: any)Parameters
| Parameter | Type | Description |
|---|---|---|
callback | Function | Function to call. |
callstack | {CallFrame} | Array of frames with func and integer currentline fields. |
options | TrampolineOptions | Table with optional script, identity, env, and thread context fields. |
...args | any | Arguments forwarded to the callback. |
Argument fields
Luau
CallFrame = {func: Function, currentline: number}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
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