Sorry, I'm still learning about lua. Could you please correct me, why the data from the file will not read line by line?
this is my example data in points.txt file :
lexxo:30:1
rey:40:2
lion:40:2
prince:50:3
royal:50:3
so when i got on top it's a 2d array (table)
player = {{(name),(points),(which var point earned on index)},
{(...),(...),(...)}};
so the problem is that I am trying to execute a loop to print all the data in a file. it just prints only the last line. so I wanted to 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[
end
for i = 1,
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
source
share