So I have a table where I want to insert a number into and I want it to be in the second key "[2]" but I wanted to know if it's possible.
✓ ANSWER ACCEPTED
Can you make table.insert insert the value to a specific place in the table?
1 answer
✓ Accepted answer
In lua you can do exactly what you want with the table.insert(t, i, v)
Example:
local t = {}
table.insert(t, 2, value) -- Where 2 is the index you are inserting the value to
2 comments
0
oh nice to know
0
Learning something new everyday :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
tab[2] = value
Yeah it works. But you can't use table.insert to do that unfortunately https://gyazo.com/5910c7a1c3a2464aec58f9c8e307806e
You actually can you table.insert to do that. table.insert(table, index, value)