ReferenceDebug

isvalidlevel

Checks whether a visible caller level exists.

Syntax

isvalidlevel(level: number) -> boolean

Also available as

validleveldebug.isvalidleveldebug.validlevelis_valid_levelvalid_level

Parameters

ParameterTypeDescription
levelnumberVisible caller level to test.

Returns

TypeDescription
booleanWhether the level names an available frame.

Description

Use this before inspecting an optional outer frame. It tests the current call stack, not a Lua function’s number of constants, upvalues or prototypes. Stack depth changes as functions enter and return.

Example

print(isvalidlevel(1))
print(isvalidlevel(100000))

These are Game executor contracts. Check build requirements and session lifetimes before using them.