Skip to main content

luav_getItemWithIndex function

The luav_getItemWithIndex function retrieves a value from a Lua table referenced by a LUAVALUE handle, using a numeric index.

This helper is primarily intended for accessing array-like elements of the identifier or options table passed to the FSMDEV_OPEN callback function.

Syntax

LUAVALUE luav_getItemWithIndex(
LUAVALUE lv,
size_t index
);

Parameters

ParameterTypeDescription
lvLUAVALUEA handle referencing a Lua value expected to be a table.
indexsize_tThe index of the table element to retrieve.

Return Values

  • If lv refers to a Lua table and the specified index exists, returns a LUAVALUE referencing the corresponding table element.
  • If the specified index does not exist in the table, returns a LUAVALUE representing Lua nil.
  • If lv does not refer to a Lua table, returns a LUAVALUE representing Lua nil.

Remarks

  • This function performs a read-only table lookup and does not modify the Lua table.
  • The returned LUAVALUE may represent any Lua value type, including nil.
  • To test whether the returned value is nil, use the luav_isNull function.
  • This function does not raise an error for out-of-range indexes or non-table values; such cases are represented by a nil Lua value.
  • Lua Value Access Helper functions are not thread-safe; concurrent execution of functions that accept a LUAVALUE is not allowed.
  • The lifetime of a LUAVALUE is limited to the execution of the callback function that received it; accessing it after the callback returns is prohibited.

See Also