0

所以我的 lua 脚本显示了双重结果:

在此处输入图像描述

它应该只显示每种流体中的一种。

这是脚本的一部分:

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编辑 这是2个完整的代码:

4

1 回答 1

1

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

编辑-通过表格,我的意思是“阵列”机器

调试表“数组”的代码将其放在您放置在问题上的代码部分之前。

for k, v in pairs(machines) do
  print(tostring(k)..": "..tostring(v))
end
于 2014-07-26T11:13:00.183 回答