View Single Post
12/16/23, 02:21 PM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
Originally Posted by sinnereso View Post
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.
  Reply With Quote