Originally Posted by sinnereso
Im looking for a way to determine the number of entries on the fly for a chat multiiple event filter im working on for the "FOR" statement. Ive been getting errors stating its expecting a number with this setup.
Code:
MyAddon.killFilterList = {}
function MyAddon.PvpKillFeedFilter(victomDisplayName)--<< PVP CHAT FEED MULTIPLE EVENT FILTER
for i = 1, MyAddon.killFilterList do
if (nil == MyAddon.killFilterList[victomDisplayName]) then
table.insert(MyAddon.killFilterList, victomDisplayName)
return false
end
end
return true
end
I'd like to to just scan the list and add entries theyre not present.
then later clear the list which I think I can do with "MyAddon.killFilterList = {}" but untested untill the 1st part is working.
Suggestions?
|
You are passing the table "MyAddon.killFilterList" to "for .. do" instead of the length of the table "#MyAddon.killFilterList".
Other than you are mixing two different approaches on how to use tables and end up not filtering anything at all.
You iterate over the table and insert new entries into it with numeric indexes, but at the same time try to access entries in the table by using the displayName as a key (instead of the numeric index).
Code:
MyAddon.killFilterList = {}
function MyAddon.PvpKillFeedFilter(victomDisplayName)--<< PVP CHAT FEED MULTIPLE EVENT FILTER
if not MyAddon.killFilterList[victomDisplayName] then
MyAddon.killFilterList[victomDisplayName] = true
return false
end
return true
end
Aside of that you will have to unset the entry in the killFilterList at some point, otherwise you won't ever show the name again after it got filtered the first time.