i have some problem in my array2d. i actually want plan to have refresh command.
my data on data.txt
test1:30:1
test2:40:2
So whenever i call function ReadData. It will send to my Array2d something like this :
line_data = {{"test1", "30", "1"},
{"test2", "40", "2"}}
But the problem is every i call the function. it will always adding same data, i would like to just do refresh or replace maybe, when i do some event. my code
line_data = {}
function ReadData()
local file = io.open("data.txt", "r")
for line in file:lines() do
line_data[#line_data+1] = { line:match('([^:]+):(%d+):(%d+)') }
end
end
maybe you guys can help me with this situation ?
line_data = {}. actually have null at the beginning. i just declare it to array for being a saved array with contain value whenever i try call function read