我正在编写一个脚本,以便在使用 MPV 时在每个视频的 .txt 中添加一行。
但是,我在第 68 行的 for 循环中遇到了一个奇怪的错误。它只是告诉我:没有错误。如果我向 file:write(message, error) 添加错误参数,它会给我另一条错误消息,说明:bad argument #2 to 'write' (string expected, got function)
. 任何帮助,将不胜感激。
function on_file_end(event)
if not paused then totaltime = totaltime + os.clock() - lasttime end
local message = (totaltime .. "s, " .. timeloaded .. ", " .. filename)
local lines = {}
local file = io.open(logpath, "r+")
if file_exists(logpath) then
for l in file:lines() do
if not l:find(message, 1, true) then
lines[#lines+1] = 1
file:write(message)
end
end
file:close()
end
end