I have got the following code:
function getusers(file)
print (type(file))
for line in file:lines() do
user, value = string.match(file,"(UserName=)(.-)\n")
print(value)
end
f:close()
end
f = assert(io.open('file2.ini', "r"))
t = f:read("*all")
getusers(t)
The return of:
print(type(file))
is type string. Lua returns me the error code:
lua: reader.lua:3: attempt to call method 'lines' (a nil value)
I don't know how to fix this problem. If I just use the lines between the for and the end (the lines in the for loop) it works great.