I am logging video files I have played through MPV and while using io I want it to create one line per video. Using the inital options it merley deletes it, and upon going to next video, it won't add new line by default.
I think the script should be close to working. However, this issue stands in my way: "bad argument #1 to '(for generator)' (invalid option). Apparently, something is wrong with the for loop, but I am unable to pinpoint it and would appreciate a pair of hands in solving this problem as I am still learning lua.
Here's the code so far:
if not paused then totaltime = totaltime + os.clock() - lasttime end
message = (totaltime .. "s, " .. timeloaded .. ", " .. filename)
local file = io.open(logpath, "r+")
local lines = {}
if file_exists(logpath) then
for l in file:lines('L') do
if not l:find(message, 1, true) then
lines[#lines+1] = 1
file.write(message)
file:close()
end
end
end
end