natiny_script_table_get_length
C
uint32_t natiny_script_table_get_length(NatinyScript script, NatinyScriptValue table);
Returns the raw length of the table's array part, equivalent to Lua's length
operator when no __len metamethod is involved.
Parameters
| Name |
Type |
Description |
script |
NatinyScript |
The state the table lives in |
table |
NatinyScriptValue |
The table to measure |
Returns
| Type |
Description |
uint32_t |
The length, or 0 for an empty table or a handle that names none |
Example
C
uint32_t count = natiny_script_table_get_length(script, mods);
for (uint32_t i = 1; i <= count; ++i) {
NatinyScriptValue name = natiny_script_table_get_item(script, mods, i);
if (name.type == NATINY_SCRIPT_STRING)
load_mod(name.string.data, name.string.size);
}