Reputation: 119
So my lua script is showing double results:
It should only show one of each type of fluid.
This is the part of the script :
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
I though it was not ending the showing with a "," "." or a ")" but that doesn't seem to be the case. How can i fix this?
Pastebin edit This are the 2 complete codes:
Upvotes: 0
Views: 401
Reputation: 108
After taking a look at this i would suggest taking a look into what your table looks like because the code posted above does not seem to have anything wrong with it, BUT if your table some how duplicated the machines then it would certainly print it out twice, that's where i would start to look.
Edit - and by table i mean the "array" machines
Code to debug the table "array" put this before the section of code you placed on your question..
for k, v in pairs(machines) do
print(tostring(k)..": "..tostring(v))
end
Upvotes: 1