Skip to main content
Checks whether a number is a valid stack level for the thread that calls it.
New to stack levels? Learn more here. It tracks debug.getinfo exactly: a level this returns true for is one debug.getinfo can read, and a level it returns false for is one debug.getinfo errors on.

Parameters

Returns

boolean - true for a level the calling thread currently has on its stack, false for one it does not.

Aliases

  • isvalidlevel
  • validlevel

Example

Measure how deep the current call stack is by counting levels until debug.isvalidlevel runs off the top.
Useful for iterating up the stack without causing stack level out-of-range errors.