I want to create 1, specific string and then put them into the array like this:
local myString = "example string"
and then get in result:
local myList = {"e","x","a","m", etc. }
you use string.gmatch()
and use the "." string pattern, which is every character inside a string. then just literate over it and insert each character into a table.
local myString = "example string" local myTable = {} for character in string.gmatch(myString,".") do table.insert(myTable, character) end
then if you want, you can literate over the table and print each character or value.
for _,v in pairs(myTable) do print(v) -- just prints the value or the character end
This is easily done with just string.sub and a basic for loop.
function getChars(InputString) local ret = {} for local i = string.len(InputString), 1, -1 do -- For every character ret[i] = string.sub(InputString,_,_) -- Add this character to the table end return ret end