natiny.script.table_get_length

Lua
natiny.script.table_get_length(script, table) -> number

Returns the raw length of the table's array part - what # gives over there when no __len metamethod is involved.

Parameters

Name Type Description
script number The script the table lives in
table reference The table to measure, from make_table

Returns

Type Description
number The length, or 0 for an empty table

Example

Lua
local list = natiny.script.make_table(mod)
natiny.script.set(mod, "enabled_mods", list)
natiny.script.call(mod, "collect_mods")       -- the mod appends to it

for i = 1, natiny.script.table_get_length(mod, list) do
    print(natiny.script.table_get_item(mod, list, i))
end

A copy has its own #, so this is for a table you keep a reference to - one the other script goes on changing between reads.