在 Lua 中收集数据

我对编写 Lua 还比较新手,但这应该是一个相对简单的解决方案。

我正在分析打印出来的数据。我希望能够将打印出来的数据保存在一个文件中,比如记事本,以便将储存在文件中的值打印出来。例如:

if VariableOne == nil and VariableTwo ~= nil and VariableThree == true then
    if VariableTime == nil then
        VariableTime = GetTime()
    end
    else if VariableTime ~= nil then
        print("Variable values have been met for "..GetTime() - VariableTime)
        VariableTime = nil
    end
end

我希望它能以列表的形式收集计时器,以便我可以在 Excel 中使用:

34.2
43.3
12.2
45.7
...
点赞
用户1009479
用户1009479

如果你想将数据写入到一个文件中,可以打开文件并将数据写入:

local f = assert(io.open('output.txt', 'w'))
f:write(tostring(GetTime() - VariableTime) .. '\n')
-- 写入更多数据
f:close()

想了解更多信息,请阅读 PiL:I/O 库

2015-06-04 02:02:51