So I have a table that contains tables that holds a line from a text file, so if the file's first line is "0,0,0,50" then table = { 1 = {a = "0,0,0,50"} 2 = { a = "LINE 2"} 3 = { .....etc. } I want to seperate t[1][a] by commas and store each of them in their respective places within the table.
so what I want to do is have it like this:
table = {
1 = {
a = "0,0,0,50"
1 = 0
2 = 0
3 = 0
4 = 50
}
}
What I have so far:
function split_comma_String()
local b = tablelength(t)
print(t[1].a)
print(b)
repeat
local k = 1
local tak = t.a
print(tak)
for v in string.gmatch(tak, "%w+") do -- error in "%w+" Want to seperate by comma (,)
t[k] = v
k = k + 1
print(b,b,t[k])
end
b = b - 1
until b == 0
end
Nothing that I put in the quotes seems to work. If someone could explain why this is not working that would be very helpful.