pixelscript 0.5.4

Multi language scripting runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- Only included if `pxs_utils` feature set. This goes into GLOBAL scope.

function _pxs_items(t)
    -- Get keys and values of a table and return them 
    -- as a table list of {{key, item}, ...}
    local items = {}
    local keys = {}
    for key in pairs(t) do
        table.insert(keys, key)
    end
    table.sort(keys) -- Sort keys to ensure consistent order
    for _, key in ipairs(keys) do
        table.insert(items, { key, t[key] })
    end
    return items
end