I've seen it here and there but never understood what it is used for, could someone explain what unpack() is for?
What is unpack used for?
Unpack is used for separating values in a table for example
local Table = {"g","o","o","d","a","d","m","i","n","s"} -- This is my Table print(unpack(Table)) -- This unpacks the table and prints it as separate values
Output
g o o d a d m i n s
This prints all the content of the table in one line
local t = {"1","2","3","4","5"} print(unpack(t))
Above code prints out each element in 't', starting from index 1. A brief explanation would be as follows:
unpack is a special function in Lua which receives a specified table and returns the elements in that table in consecutive order, starting from index 1.