so for example i have a string value like, “8741”
and i wanted to turn it into a table like,
{8, 7, 4, 1}
how can i achieve this with code?
so for example i have a string value like, “8741”
and i wanted to turn it into a table like,
{8, 7, 4, 1}
how can i achieve this with code?
You can use the string.split
function with a blank string as the separator:
local text = "8741"
local stringAsTable = string.split(text, "")
print(stringAsTable)
Use a string iterator function and convert the the character into a number with tonumber(), then insert it into your table with table.insert().
If you don’t know how to iterate over a string, you can find it on the internet easily with one quick search.