As of right now I am using table.insert(table, position in table, item) to add items to a table, and using a for loop to add things from another table to it, but I also have to add a counter to it so that for the position in the table it is always one more than the last. This seems tedious to me (even if it is only a couple lines) so I was wondering if there was anything similar to appendItem() from javascript that I just don't know about. I also couldn't find anything about it in the lua documentation. Thanks for any answers!

5 comments

0

you could get the length of the table and add 1 to it and that would solve the issue of repetition you can access the table's length by using #(tablenamehere) and add 1 to it in parentheses.

0

table.Insert(MyTable, #MyTable + 1, item)

0

@Mr_Pure thanks, I might use that. I'll mark this question as answered. Would upvote but can't.

0

If you omit the position argument, it defaults to the index after the end of the list.

0

@RayCurse Ah that's more straightforward than I figured, thanks