debug.validlevel

Checks if a stack level is valid.

Syntax

debug.validlevel(level: number, thread?: thread) -> boolean

Aliases

  • debug.isvalidlevel

Parameters

ParameterTypeDescription
levelnumberThe stack level
threadthread?Thread to inspect; defaults to the current thread

Returns

TypeDescription
booleanTrue if the stack level is valid

Description

debug.validlevel checks whether a given stack level exists and is valid for debugging operations.

Example

-- Check stack levels
for i = 0, 10 do
    if debug.validlevel(i) then
        print("Level " .. i .. " is valid")
    else
        print("Level " .. i .. " is invalid")
        break
    end
end