Volt

debug.getcallstack

Gets the current call stack.

Syntax

debug.getcallstack(level: number?) -> table

Parameters

ParameterTypeDescription
levelnumber(Optional) Starting level, default 1

Returns

TypeDescription
tableArray of call stack entries

Description

debug.getcallstack returns information about the current call stack, including function names and source locations.

Example

local function innerFunc()
    local stack = debug.getcallstack()
    for i, entry in ipairs(stack) do
        print(i, entry.name or "anonymous", entry.source)
    end
end

local function outerFunc()
    innerFunc()
end

outerFunc()

Entry Fields

FieldDescription
nameFunction name
sourceSource file/script
lineCurrent line number
funcThe function itself

On this page