Converting an array into a tuple

Yesterday, I tryed to do a Script that would convert an array of numbers into a string with utf8.char() but this only works for tuples… I can convert tuples into arrays but I can’t find out any way to reverse-it!

print(utf8.char(72,101,108,108,111,33)) --Print "Hello!"
local A = {72,101,108,108,111,33}
print(utf8.char(A)) --Throws an error

In this Script I’d like to know a way to convert the array A into a tuple (the array can do any sizes!)
I already looked for something like totuple() but there isn’t nothing that correspond :frowning:

unpack(t) is your friend.

print(utf8.char(72,101,108,108,111,33)) --Print "Hello!" 
local A = {72,101,108,108,111,33}
print(utf8.char(unpack(A))) -- "Hello!" again

From the wiki:

It basically returns t[i], t[i+1], t[i+2] ... t[j]. Without providing both i and j, it returns everything in the table.

EDIT: Just be warned that there’s a limit to this. You can’t unpack very large arrays.

1 Like

The limit is 8000, minus one for each argument to unpack (7999 in this case)

1 Like

Any way I don’t need to unpack an very large array (it’s for commands recognition that uses not more than 64 letters normally :slight_smile:
So… Thanks for supporting-me and to reply very fast! :smile: