I am working on a table where I need to make a custom index, how exactly would I be able to do this?
The table library currently does not operate on dictionaries. Now, more along the lines of the spirit of your enquiry, you can use this function:
local function setKeyAndValue(t, k, v) t[k] = v end local tbl = {} setKeyAndValue(tbl, "Key", 2) print(tbl.Key)
Which just sets the key and values. Pretty self explanatory.
With table.insert(list, pos, value)
you can set value to be at position pos
. insert shifts the indices to the right by 1 if the index is not nil.
local tbl = {"hello", "world", "yes", "no"} table.insert(tbl, 1, "goodbye") print(table.concat(tbl, ", ")) --> goodbye, hello, world, yes, no
goodbye is placed at index 1, and hello, formerly index 1, is shifted down so is everything else.