Lua 双重结果显示

我的 Lua 脚本显示了双倍的结果:

enter image description here

它只应该显示每种流体的一个结果。

这是脚本的一部分:

function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end
function dispTanks()
mon.setCursorPos(offsetPos, 1)
mon2.setCursorPos(offsetPos,1)

    for i=1, #machines do
    -- RC Tanks --------------------------------------------
        if string.find(machines[i], "rcirontankvalvetile")
            or string.find(machines[i], "rcsteeltankvalvetile") then

            if peripheral.isPresent(machines[i]) then
                periph = peripheral.wrap(machines[i])

                fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID = marik.getTank(periph)

                if fluidName == nil then
                -- does not display empty tanks
                elseif fluidName ~= nil then
                    mon2.setTextColor(tc)
                    x,y = mon2.getCursorPos()
                    mon2.setCursorPos(offsetPos, (y+1))
                    mon2.clearLine()
            -- marik.cString(offsetPos,(y+1), tc, right, ",")
            nameFL = firstToUpper(marik.comma(fluidName):match("[^.]*"))
            mon2.write("Tank (" .. nameFL .. ") :  " .. marik.getBuckets(fluidAmount) .. " buckets")
        end
        end
    end
    end
end

我认为这不是以“,”“。”或“)”结束显示导致的问题,但情况并非如此。如何解决这个问题?

Pastebin 编辑 这是两个完整的代码:

点赞
用户3189167
用户3189167

在查看了这个代码之后,我建议你看一下你的表长什么样子,因为你上面发布的代码似乎没有任何问题,但是如果你的表上重复了机器,那么它肯定会打印两次,这就是我要开始查看的地方。

编辑 - 通过表格,我是指“数组”机器

调试表格“数组”的代码,请在你在问题中放置的代码部分之前放置以下代码..

for k, v in pairs(machines) do
  print(tostring(k)..": "..tostring(v))
end
2014-07-26 11:13:00