sorry i am still learning about lua. could you correct me, why the data from file wont read line by line ?
this is my example data in file points.txt :
lexxo:30:1
rey:40:2
lion:40:2
prince:50:3
royal:50:3
so when i got from above is the 2d array(table)
player = {{(name),(points),(which var point earned on index)},
{(...),(...),(...)}};
so the problem is, when i try to loop for printing all of data in file. it just print only the lastest line. so what i wanted print all of them
line_points = {}
player_data = {{}}
local rfile = io.open("points.txt", "r")
for line in rfile:lines() do
playername, playerpoint, playeridpoint = line:match("^(.-):(%d+):(%d+)$")
player_data = {{playername, playerpoint, playeridpoint}}
line_points[#line_points + 1] = player_data
end
for i = 1, #player_data do
player_checkname = player_data[i][1] -- Get Player Name From Array for checking further
player_checkpnt = player_data[i][3] -- Get Player ID Point From Array for checking further
print(i..". Name: "..player_data[i][1].." Point: ".. player_data[i][2] .. " ID: " .. player_data[i][3]);
end
print(line_points[1][2])
– Devora