natiny.script.table_set_item

Lua
natiny.script.table_set_item(script, table, index, value)

Writes a numbered entry of a table.

Parameters

Name Type Description
script number The script the table lives in
table reference The table to write, from make_table
index number Position, counted from 1 as Lua counts; negative is an error
value any What to store - see script values

Example

Lua
local list = natiny.script.make_table(mod)
natiny.script.set(mod, "game.enabled_mods", list)

-- Mods enabled later are appended to the same list.
local function enable(name)
    local n = natiny.script.table_get_length(mod, list)
    natiny.script.table_set_item(mod, list, n + 1, name)
end